日志格式
# vi /usr/local/nginx/conf/nginx.conf //搜索log_format
####定义日志格式
log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
' $host "$request_uri" $status'
' "$http_referer" "$http_user_agent"';
注:combined_realip日志格式的名字$remote_addr访问的ip是?$http_x_forwarded_for 代理服务器ip,如果使用代理,则会记录代理的ip$time_local当前时间$host 访问的主机名称或者域名$request_uri 访问的地址$status 状态
除了在主配置文件nginx.conf里定义日志格式外,还需要在虚拟主机配置文件中增加
access_log /tmp/1.log combined_realip;

其中combined_realip;为你主配置文件里面定义的名称
这里的combined_realip就是在nginx.conf中定义的日志格式名字
# /usr/local/nginx/sbin/nginx -t //验证是否正确
# /usr/local/nginx/sbin/nginx -s reload 从新加载
# curl -x127.0.0.1:80 test.com -I
# cat /tmp/1.log


