修改 Nginx 配置文件 /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 /data/wwwlogs/manage.qyfou.com_nginx.log main;
Qi 问的问题 2020年9月28日