Skip to content

Instantly share code, notes, and snippets.

@mustache1up
mustache1up / log-http-headers.md
Created May 9, 2023 06:46 — forked from kaichao/log-http-headers.md
nginx: Log complete request/response with all headers

1. switch nginx image to openresty/openresty

2. add the following to server/location (/etc/nginx/conf.d/default.conf)

   set $req_header "";
   set $resp_header "";
   header_filter_by_lua_block{ 
      local h = ngx.req.get_headers();
      for k, v in pairs(h) do
         ngx.var.req_header = ngx.var.req_header .. k.."="..v.." ";