我们用的nginx有做过一些定制开发,为了调试方便,加了一些自定义的response header,那么如何把这个自定义头记录到日志中以便于观察呢?
nginx log_format指令支持这种扩展,如下说明:
The headers, transmitted to client, begin from the prefix "sent_http_", for example, $sent_http_content_range. Note that variables produced by other modules can also be logged. For example you can log upstream response headers with the prefix "upstream_http_", see upstream .
wiki地址:http://wiki.nginx.org/HttpLogModule
举例:如果你自定义的响应header是My_Custom_Header,那么只需要在log_format中增加$sent_http_my_custom_header即可
PS:nginx对header的处理是大小写不敏感的。
本文介绍如何在Nginx中记录自定义的HTTP响应头信息至日志文件,通过使用log_format指令扩展,可以轻松实现对特定自定义响应头的监控。
1244

被折叠的 条评论
为什么被折叠?



