当前位置:首页 > 服务器技术 > nginx

Haproxy做代理,后端nginx获取真实用户IP


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

本文出自 “ˉ、穎濤┃﹎” 博客,请务必保留此出处http://hypocritical.blog.51cto.com/3388028/1675267

原文:http://hypocritical.blog.51cto.com/3388028/1675267


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!