How to get non-standard HTTP headers on nginx?

2019-03-14 10:28发布

I have a very simple question to the nginx experts out there. This 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?

标签: http nginx
1条回答
淡お忘
2楼-- · 2019-03-14 11:11
登录 后发表回答