nginx日志格式

时间:2024-01-13 15:22:14

日志格式

log_format main '$remote_addr - $remote_user [$time_local] $request '
                    '"$status" $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';

log_format main1 '$proxy_add_x_forwarded_for - $remote_user [$time_local] ' 
                      '"$request" $status $body_bytes_sent '
                      '"$http_referer" "$http_user_agent"';  //此日志格式为,ip不仅记录代理的ip还记录远程客户端真实IP。

在nginx虚拟主机中分别用main main1 引用即可。