如何在nginx上获取非标准HTTP头? [英] How to get non-standard HTTP headers on nginx?
问题描述
我对那里的nginx专家提出了一个非常简单的问题。这可能是一个错误。
I have a very simple question to the nginx experts out there. This is possibly a bug.
在nginx 1.0.5中,给出以下nginx.conf:
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/
...但这不是。
$ curl -H "MY_CUSTOM_HEADER: Yes" http://myserver/
后者case,参数传递给我的uwsgi应用程序,但它只是一个空字符串。我知道HTTP标头应该是不区分大小写的,但是当标头不遵循通常的格式(标题,下划线而不是破折号)时,nginx行为是意料之外的。
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).
任何人都有类似的需要捕获自定义标头?任何nginx.conf示例?
Anyone had similar need to capture custom headers? Any nginx.conf examples?
推荐答案
没关系,弄清楚它有一个设置:
Nevermind, figured out there's a setting to it:
http://nginx.org/en/docs/http /ngx_http_core_module.html#underscores_in_headers
这篇关于如何在nginx上获取非标准HTTP头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!