1)修改haproxy配置文件,添加如下参数:
option httpclose
option forwardfor
2)修改nginx配置文件,添加如下参数 注意:需要编译模块--with-http_realip_module
#haproxy服务器IP
set_real_ip_from 192.168.64.128;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
3)分别重启haproxy和nginx
/etc/init.d/haproxy restart
/etc/init.d/nginx restart
来源:oschina
链接:https://my.oschina.net/u/4323284/blog/4317769