-1

I'm trying to use nginx. My existing application sends headers in all lowercase letters.

For example:

device-id, content-type

But Nginx is changing the headers. The headers above are translated as follows.

Device-Id, Content-Type

I've tried ignoring invalid headers.

ignore_invalid_headers on;

But there was no change. I tried this setting in both server definition and http definition. There was no change.

I don't want nginx to make any changes to the headers. How can I achieve this?

hkucuk
  • 172
  • 1
  • 2
  • 14
  • If your application use HTTP/2, this is an expected behavior, read [this](https://stackoverflow.com/a/64967893/7121513) answer. – Ivan Shatsky May 24 '21 at 12:50
  • no, the opposite is the expected situation. In HTTP / 2, all headers are sent in lowercase. – hkucuk May 25 '21 at 19:37
  • Yes, but if nginx communicates with your upstream through HTTP/1.0 or HTTP/1.1 protocol, it will convert all the headers to HTTP/1 standard capitalizing the first letters. – Ivan Shatsky May 25 '21 at 19:48

1 Answers1

-1

First of all, it should not matter to you, or to anyone, what is the case of headers.

HTTP header names are non case-sensitive.

What you see is likely not NGINX at all changing the case, but curl doing this or another program where you check the HTTP headers. In fact, NGINX by default has nothing to do with your headers and it does not alter them in any way.

Danila Vershinin
  • 6,133
  • 2
  • 20
  • 25
  • header fields are case sensitive when using PHP to get the value of a header field using the method 'apache_request_headers()'. – hkucuk May 23 '21 at 20:02
  • The [comment](https://www.php.net/manual/en/function.apache-request-headers.php#124236) on the PHP manual has got it right by saying `if you want to be standards compliant, you must loop through every key and check it in a case-insensitive manner, instead of doing the obvious thing and using the name of the header as an array index` – Danila Vershinin May 23 '21 at 21:20