Does nginx ignore/discard headers that have no value i.e empty value?

Please use this template for troubleshooting questions.

My issue: Request headers with empty values are ignore

How I encountered the problem: In my module, I am reading the headers. When iterating over headers_in list, I don’t find header with empty values.

Solutions I’ve tried: I’ve printed all headers received in the request. I am reading the request in post_read phase.

Version of NGINX or NGINX adjacent software (e.g. NGINX Gateway Fabric): 1.28.0

Deployment environment: docker container.

Minimal NGINX config to reproduce your issue (preferably running on https://tech-playground.com/playgrounds/nginx for ease of debugging, and if not as a code block): (Tip → Run nginx -T to print your entire NGINX config to your terminal.)

NGINX access/error log: (Tip → You can usually find the logs in the /var/log/nginx directory.)

1 Like

AFAIK, nginx discards empty request headers as they are technically invalid.
FWIW, you will see the same behavior when iterating over headers with njs

Similarly, curl will not send empty request headers.

Thanks for responding @liam. Yeah, nginx does seem to discard the headers towards the proxy. However, I was interested in reading the headers from the request (headers_in) in my module which should have been available. Turn out, they are available. It was my test that was wrong. I was using curl to send my request which was silently dropping it. As a result, I thought nginx wasn’t reading empty headers. That’s not the case. It is reading the empty headers properly.

1 Like