###nginx日志格式案例(一)html
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
【ngx_http_proxy_module中】 $proxy_add_x_forwarded_for 将$remote_addr变量值添加在客户端“X-Forwarded-For”请求头的后面,并以逗号分隔。 若是客户端请求未携带“X-Forwarded-For”请求头,$proxy_add_x_forwarded_for变量值将与$remote_addr变量相同。
###nginx日志格式案例(二)nginx
log_format main '$host ' //“Host”请求头的值,若是没有该请求头,则为与请求对应的虚拟主机的首要主机名 '$server_addr ' //接受请求的服务器地址 '$remote_addr ' //客户端IP地址 '- ' '"$time_local" ' '$status ' '$body_bytes_sent ' '$request_time ' //请求处理的时间,单位为秒,精度是毫秒(1.3.9, 1.2.6);请求处理时间从由客户端接收到第一个字节开始计算 '"$http_referer" ' //告诉服务器我是从哪一个页面连接过来的 '"$request" ' '"$http_user_agent" ' '$pid'; //处理请求的nginx进程id
参考1浏览器