Rootop 服务器运维与web架构

nginx日志记录客户端post的数据

官方文档:http://nginx.org/en/docs/http/ngx_http_core_module.html#var_request_body

通过在日志格式中加入 $request_body 变量实现记录。
这种方式不推荐配置在日志格式中,仅用于排查问题时使用,否则客户端上传图片之类的文件,日志会非常的大。

注意官方文档中提到:
request body
The variable’s value is made available in locations processed by the proxy_pass, fastcgi_pass, uwsgi_pass, and scgi_pass directives when the request body was read to a memory buffer.

只有在location中通过 proxy_pass、fastcgi_pass、uwsgi_pass、scgi_pass代理的时候才会记录。

原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/4730.html

作者:Venus

服务器运维与性能优化

评论已关闭。