2016-03-15 83 views
1

我有這個nginx.conf自定義頁眉在Nginx的

server { 

listen <%= ENV['NGINX_IP'] %>:<%= ENV['NGINX_PORT'] %>; 
server_name proxy-oapp.rhcloud.com; 

    location/{ 
    proxy_set_header X-Real-IP $remote_addr; 
    #proxy_set_header Host $http_host; 
    proxy_set_header X-forwarded-for $proxy_add_x_forwarded_for; 
    proxy_set_header X-NginX-Proxy true; 
    proxy_pass https://app-oapp.rhcloud.com; 
    proxy_redirect off; 
    } 
    location /api { 
    proxy_set_header Host api-oapp.rhcloud.com; 
    proxy_set_header X-forwarded-for $proxy_add_x_forwarded_for; 
    proxy_set_header X-NginX-Proxy true; 
    proxy_set_header X_Auth_Token $upstream_http_x_auth_token; 
    proxy_set_header X_User_Id $upstream_http_x_user_id; 
    proxy_pass https://api-oapp.rhcloud.com/; 
    proxy_redirect off; 
    } 
} 

客戶在標頭添加認證ID和令牌: X_Auth_Token:即爲MyToken X_User_Id:MYID

但在服務器我沒有標題中的令牌。

WHY ????

回答

0

該錯誤位於下劃線中。 我必須改變這種

X_Auth_Token: MYTOKEN 
X_User_Id: MYID 

絲毫這樣的:

X-Auth-Token: MYTOKEN 
X-User-Id: MYID 
+1

你也可以用指令[underscores_in_headers(http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers)它默認關閉 – Anatoly