我能用NGINX在访问/错误日志中显示端口#吗?如果这有帮助的话我可以运行nginx调试。
Debian 11,免费NGINX 1.22下载版(非从源代码构建)
发布于 2022-09-13 20:34:15
变量上的nginx变量文档显示$server_port
变量包含请求的服务器端端口。
nginx日志模块文档文档log_format
和access_log
指令。
默认日志格式是:
log_format combined '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
可以将端口添加到末尾,例如,对于另一种日志格式:
log_format combinedwithport '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"' $server_port;
要实际对日志使用这种格式,需要定义:
access_log /path/to/log/file combinedwithport;
建议将端口添加到日志行的末尾,以便可能的组合日志格式解析器仍然可以处理日志。
https://serverfault.com/questions/1110654
复制相似问题