对nginx反向代理日志json格式化
2021-02-07 03:17
标签:ansi 步骤 mic style ror sel main orm mode 反向代理日志 步骤 使用ansible用户登录反向代理服务器 cd /etc/nginx/ 修改配置文件nginx.conf sudo vi nginx.conf 将 log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘ 改为 log_format json ‘{"request_id": "$request_id",‘ 重新加载nginx sudo nginx -t 对nginx反向代理日志json格式化 标签:ansi 步骤 mic style ror sel main orm mode 原文地址:https://www.cnblogs.com/xiaoyuxixi/p/13096767.htmljson
化
‘$status $body_bytes_sent "$http_referer" ‘
‘"$http_user_agent" "$http_x_forwarded_for"‘;
?
access_log /var/log/nginx/access.log main;
‘"remote_addr": "$remote_addr",‘
‘"time_iso8601": "$time_iso8601",‘
‘"request": "$request",‘
‘"status": "$status",‘
‘"body_bytes_sent": "$body_bytes_sent",‘
‘"http_referer": "$http_referer",‘
‘"http_user_agent": "$http_user_agent",‘
‘"http_x_forwarded_for": "$http_x_forwarded_for",‘
‘"request_time": "$request_time",‘
‘"upstream_response_time": "$upstream_response_time",‘
‘"upstream_addr": "$upstream_addr",‘
‘"upstream_connect_time": "$upstream_connect_time",‘
‘"upstream_status": "$upstream_status" }‘;
?
access_log /var/log/nginx/access.log json;
?
sudo nginx -s reload
文章标题:对nginx反向代理日志json格式化
文章链接:http://soscw.com/index.php/essay/52003.html