【问题标题】:Custom Headers in NginxNginx 中的自定义标头
【发布时间】:2016-03-15 22:19:57
【问题描述】:

我有这个 nginx.conf

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

但在服务器中,我在标头中没有令牌。

为什么????

【问题讨论】:

    标签: ruby-on-rails nginx reverse-proxy


    【解决方案1】:

    错误在下划线中。 我必须改变这个

    X_Auth_Token: MYTOKEN 
    X_User_Id: MYID
    

    这个:

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

    【讨论】:

    猜你喜欢
    • 2015-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-22
    • 2019-02-19
    • 2021-03-09
    • 2021-02-22
    • 2020-11-03
    相关资源
    最近更新 更多