ITeye博客

HTTP_X_REAL_IP

123003473 · 2015-04-20 17:50 · http · 行业应用 · Markdown

$_SERVER;得到的都是服务器的地址

$_SERVER;得到的都是客户端的地址

nginx 代理模式下,获取客户端真实IP 在nginx中设置:

proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

后端程序可以从Server变量HTTP_X_REAL_IP和HTTP_X_FORWARDED_FOR中获取用户的ip地址。

HTTP_X_REAL_IP的值是nginx得到的用户REMOTE_ADDR

参考地址:http://doubao.javaeye.com/blog/427619

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。