set_real_ip_from 172.16.100.120; #haproxy 的IP地址 set_real_ip_from 172.16.100.110; #haproxy 的IP地址 real_ip_header X-Forwarded-For; log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘ ‘$status $body_bytes_sent "$http_referer" ‘ ‘"$http_user_agent" "$http_x_forwarded_for"‘;
nginx配置文件设置如上
后端nginx服务可以取得用户访问的真实ip地址。
本文出自 “好记性不如烂笔头” 博客,请务必保留此出处http://cobweb.blog.51cto.com/390607/1735299
原文地址:http://cobweb.blog.51cto.com/390607/1735299