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