I need to make NGINX ignore / modify a request header.
Problem is some IoT devices are sending a HEAD request with the wrong Content-Length header. That makes NGINX wait for more content and then timeout.
Both dropping the Content-Length header or setting it to 0 should do the trick.
Example
This fails
HEAD / HTTP/1.1
Host: MY_HOST
Content-Length: 59
Content-Type: text/html
Connection: close
This works (Content-Length: 0)
HEAD / HTTP/1.1
Host: MY_HOST
Content-Length: 0
Content-Type: text/html
Connection: close
This works too (no Content-Length)
HEAD / HTTP/1.1
Host: MY_HOST
Content-Type: text/html
Connection: close
How can I make it happen?
I discovered that there's a NGINX module named HeadersMore that allow modifying input headers (and more).
In particular more_clear_input_headers allows to remove input headers and more_set_input_headers allows to modify input headers.
In my case
more_clear_input_headers "Content-Length";
or
more_set_input_headers "Content-Length: 0";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With