首先在nginx.conf中include vhost/*.conf;上面写入
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
日志的格式。
然后在server配置root /home/wwwroot/testcc;下面写入
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 末尾处
access_log /home/wwwlogs/access.log main;
reload 一下即可