tarunlalwani / nginx-lua-request-capture

This repo demonstrates how to capture any incoming request and write it as JSON to nginx log using Nginx and Lua. For more details refer to http://tarunlalwani.com/post/request-capturing-nginx-lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Query on Content-Length response header

SudharsanN opened this issue · comments

We are using your repo to troubleshoot a production issue wherein we were receiving 'Duplicate Content-Length' error while making a call to an API. So, we introduced a proxy between the application and the API. Ever since we introduced the proxy the issue disappeared. We are pretty sure that the API team didn't fix their code as they are waiting on us to capture the error scenario.

My queries here are as below.

  1. Does OpenResty or nginx or luajson that we are using is removing the duplicate content-length header if the values are same ?
  2. If the above is true, can you please point me to the docs. Also, is there a way for us to log the headers before it gets removed ?
  3. Are we inadvertently removing it as part of the lua script ?

I have attached the docker file, nginx.conf and lua script as a zip file.
Please clarify as we are lost on what exactly is happening here.
Archive.zip

You should not test it using this way. Instead put a socat forwarding to see the raw request and raw responses. See the below article for more details

https://tarunlalwani.com/post/how-to-debug-nginx-reverse-proxy-issues-php-fpm-gunicorn-uwsgi/

Thanks for the quick response. Can you let me know what is causing the duplicate content length to be removed ?