How do I get all the request headers and print them to access.log?

967 views
Skip to first unread message

cluxx

unread,
Nov 10, 2021, 7:15:22 AM11/10/21
to openresty-en
'req_header:"$req_header" | resp_header:"$resp_header" ;

set $req_header ""; set $resp_header ""; header_filter_by_lua ' local h = ngx.req.get_headers() for k, v in pairs(h) do ngx.var.req_header = ngx.var.req_header .. k.."="..v.." " end local rh = ngx.resp.get_headers() for k, v in pairs(rh) do ngx.var.resp_header = ngx.var.resp_header .. k.."="..v.." " end ';

Use openResty 1.15.8.2 to add the above configuration to nginx.conf.
Reply all
Reply to author
Forward
0 new messages