无法获取proxy_set_header的变量值

2013-11-14 10:06:47 +08:00
 lfzyx
日志格式:
log_format main '[$http_h1ost][$http_x_real_ip] [$http_x_forwarded_for] [$remote_addr] [$remote_port] [$server_addr]';

服务段:
server {
listen 80;
server_name xx.xxx.com;

#charset koi8-r;
access_log logs/access.log main ;
error_log logs/error.log debug;
location / {
proxy_pass http://xxx.com:8080;
index index.html index.htm index.jsp default.jsp index.action index.do default.action default.do;
proxy_set_header h1ost $host;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}


然后我查看日志记录,是这样的
[-][-] [-] [133.126.116.250] [52849] [131.201.192.51]
[-][-] [-] [133.126.116.250] [19025] [131.201.192.51]


也就是说我自定义的变量没有获取到,然后我搜了一下,说是要配置http部分,增加underscores_in_headers on;
但也没用,求帮助啊!
3207 次点击
所在节点    NGINX
5 条回复
julyclyde
2013-11-14 11:02:13 +08:00
proxy_set_header是给后面服务器看的
lfzyx
2013-11-14 11:04:43 +08:00
@julyclyde 什么意思?那我有什么办法去看这个值获取了没有呢?
julyclyde
2013-11-14 12:03:15 +08:00
@lfzyx proxy_pass的目标,也就是那个http://xxx.com:8080的服务器才能看到这个header
你这里是看不到的
Kvm
2013-11-14 13:28:58 +08:00
[$http_x_real_ip]去掉

$http_h1ost应该是$http_host
lfzyx
2013-11-14 13:30:40 +08:00
@Kvm 服务段我自定义了变量啊,不用nginx自带的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/89210

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX