简体   繁体   English

通过curl设置的nginx标头

[英]nginx headers set via curl

I seem to have hit a brick wall in dealing with some headers. 在处理某些标头时,我似乎遇到了麻烦。 The only place where I can think the problem is, is the nginx configuration. 我能想到的唯一问题是nginx配置。

I am making the request via curl on the command line: 我正在通过curl在命令行上发出请求:

curl -H "user-id: 1" -H "user-token: $2y$10$VgXt0CfS7UOzhYQOuH9CaeNShB2Kohs3vhyL1l8W01QzD2KiKFOgG" http://dev.api/account

Using something like http Scoop I can see the request headers: 使用类似http Scoop的东西,我可以看到请求标头:

User-Agent → curl/7.30.0

user-session → $2y$10$VgXt0CfS7UOzhYQOuH9CaeNShB2Kohs3vhyL1l8W01QzD2KiKFOgG

user-id → 1

Host → dev.api

Accept → */*

Then response I get is 然后我得到的回应是

Cache-Control → no-cache

Connection → keep-alive

Content-Type → text/html; charset=UTF-8

Date → Fri, 20 Jun 2014 03:11:02 GMT

Server → nginx/1.6.0

Transfer-Encoding → chunked

X-Frame-Options → SAMEORIGIN

X-Powered-By → PHP/5.4.28

Is there anything in nginx that would prevent the headers from the request be passed to the response? Nginx中是否有任何东西可以阻止请求的标头传递给响应?

I don`t know mechanism for all header, but for special headers add directives to location or server context: 我不知道所有标头的机制,但对于特殊标头,请将指令添加到locationserver上下文中:

add_header user-session $http_user_session
add_header user-id $http_user_id
add_header Host %http_host

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM