nginx.conf中获取到客户端自定义的header内容


underscores_in_headers on;     在http或者server下开启header的下划线支持:nginx默认不支持header中的下划线的

$http_{headerNane};  把{headerName}替换成你的真实headerName就可以了

proxy_set_header TestHeaderName testHeaderValue 在header中设置一个http的header内容

实例这是一个正向代理服务器的内容:

server {
     listen  8080;
     
     # dns resolver used by forward proxying
     resolver  114.114.114.114;
     # forward proxy for CONNECT request
     proxy_connect;
     proxy_connect_allow            443;
     proxy_connect_connect_timeout  10s;
     proxy_connect_read_timeout     10s;
     proxy_connect_send_timeout     10s;
     # more_clear_input_headers  test;
     underscores_in_headers  on;
     
    
    location / {
    
         proxy_pass http://$host;
         proxy_set_header Host $host;
#设置一个test的header值为header中的token proxy_set_header TEST $http_token; #more_clear_input_headers proxy
-token; } }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM