Custom headers - Is it a bug or what?

Hi everybody. I have a very simple question to what is possibly a bug.

In nginx 1.0.5, given the following nginx.conf:


server {
server_name myserver;

location / {
uwsgi_pass 127.0.0.1:5001;
uwsgi_param HTTP_MY_CUSTOM_HEADER $http_my_custom_header;
include uwsgi_params;
}
}

Why does this works as expected…

$ curl -H “My-Custom-Header: Yes” http://myserver/

…but this doesn’t.

$ curl -H “MY_CUSTOM_HEADER: Yes” http://myserver/

In the latter case, the parameter is passed to my uwsgi application, but
it’s just an empty string. I know HTTP headers are supposed to be
case-insensitive, but nginx behavior is unexpected when the header
doesn’t follow the usual format (title-cased, underscores instead of
dashes).

Anyone had similar need to capture custom headers? Any nginx.conf
examples?

Thanks.

Hello!

On Mon, Dec 05, 2011 at 10:13:47PM -0200, Henrique Carvalho Alves wrote:

uwsgi_param HTTP_MY_CUSTOM_HEADER $http_my_custom_header;

$ curl -H “MY_CUSTOM_HEADER: Yes” http://myserver/

In the latter case, the parameter is passed to my uwsgi application, but it’s
just an empty string. I know HTTP headers are supposed to be case-insensitive,
but nginx behavior is unexpected when the header doesn’t follow the usual format
(title-cased, underscores instead of dashes).

Anyone had similar need to capture custom headers? Any nginx.conf examples?

http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers

Maxim D.

On Mon, Dec 05, 2011 at 10:23:41PM -0200, Henrique Carvalho Alves wrote:


Anyone had similar need to capture custom headers? Any nginx.conf examples?

Module ngx_http_core_module

I knew it should be something stupid. Thank you!

To expand on this, it’s actually subject to two directives, the
above mentioned “underscores_in_headers”, and “ignore_invalid_headers”:
http://nginx.org/en/docs/http/ngx_http_core_module.html#ignore_invalid_headers

The default “underscores_in_headers on” marks headers with underscores
as invalid (I’ve just updated the documentation to mention this), and
default “ignore_invalid_headers on” ignores them. Currently nginx is
too restrictive to the headers syntax, so some setups may require
setting this directive to the value “off”.

Em 05/12/2011, s 22:17, Maxim D. escreveu:

server_name myserver;

Module ngx_http_core_module

I knew it should be something stupid. Thank you!