您的位置:首页 > 运维架构 > Nginx

Apache, Nginx获得nginx代理后的真实用户Ip

2014-03-11 18:11 344 查看
Nginx 的反向代理设置 proxy_set_header X-Real-IP $remote_addr;

apache可以设置日志格式将 %h替换为 %{X-Real-Ip}i

  如: LogFormat "%{X-Real-Ip}i %l %u %t \"%m http://%v%U%q\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" - %h" combined

nginx可以设置$http_x_real_ip变量。

  如 log_format main '$http_x_real_ip - $remote_user '
'[$time_local] "$request_method $scheme://$host$request_uri $server_protocol" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" - $remote_addr';

Nginx写的不错的博客 /article/4340860.html 排版更是顶呱呱 我的学长。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: