nginx做proxy不转发header的问题(带下划线)

使用nginx做负载均衡或http代理时,碰到http header不转发的问题。
 
配置里只有转发设置原始ip和host的
 
 
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header     X-Forwarded-Server $host;
 
 
但我自定义的header却都忽略掉了。
 
 
问题出现在对header name的字符做了限制,默认 underscores_in_headers 为off,表示如果header name中包含下划线,则忽略掉。
 
恰好我自定义的header中都是用的下划线。
 
处理办法:
 
1:配置中http部分 增加underscores_in_headers on; 配置
2:用减号-替代下划线符号_,避免这种变态问题。nginx默认忽略掉下划线可能有些原因。
 
 

猜你喜欢

转载自www.cnblogs.com/ncyhl/p/9288697.html
今日推荐