nginx lua 打印 特定 header
添加变量req_500_header
set $req_500_header "";
header_filter_by_lua '
if ngx.status >= 500 then
local h = ngx.req.get_headers()
for k, v in pairs(h) do
ngx.var.req_500_header=ngx.var.req_500_header..k..": "..v..";"
end
end
';
日志格式内增加
log_format main '{'
'"req_500_header":"$req_500_header"'
'}';
life is a jounery,yes