
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写的不错的博客 http://freeloda.blog.51cto.com/2033581/1288553 排版更是顶呱呱 我的学长。