修改 nginx.conf 并添加配置
nano /usr/local/nginx/conf/nginx.conf
在 http { }块内 添加
map $HTTP_CF_CONNECTING_IP $clientRealIp {
"" $remote_addr;
~^(?P<firstAddr>[0-9.]+),?.*$ $firstAddr;
}
log_format main '$clientRealIp [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'$http_user_agent $remote_addr $request_time';
将虚拟主机内的日志 改成 main 格式
例:access_log /home/wwwlogs/abc.com.log main;