【问题标题】:nginx / passenger configuration to allows access to custom headernginx/passenger 配置允许访问自定义标头
【发布时间】:2013-06-28 01:15:23
【问题描述】:

我正在使用一个名为 auth_token 的自定义标头,我将其传递给我的 rails 后端。在 localhost/webrick 上,我可以访问:

curl -H "auth_token: r5O_IdqpWStqmJFe0pil0Q" http://localhost:3000

并且可以通过以下方式访问标头值:

auth_token=request.headers["auth_token"] if request.headers["auth_token"]. 

但是,当我通过以下方式访问登台(nginx / 乘客)时:

curl -H "auth_token: r5O_IdqpWStqmJFe0pil0Q" http://staging.domain.com/

它无法访问标头值。我需要对 nginx/passenger 进行任何配置以允许它访问此自定义标头吗?

谢谢

【问题讨论】:

    标签: ruby-on-rails nginx passenger


    【解决方案1】:

    解决方法是:

    underscores_in_headers on;

    http://wiki.nginx.org/HttpCoreModule#underscores_in_headers

    【讨论】:

      【解决方案2】:

      如果你使用 nginx 代理模块将请求转发给乘客,则需要显式转发此自定义标头:

      proxy_set_header auth_token $http_auth_token;
      

      参考文献:

      http://wiki.nginx.org/HttpProxyModule#proxy_set_header

      http://wiki.nginx.org/HttpCoreModule#.24http_HEADER

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-07-09
        • 2022-06-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-01-23
        相关资源
        最近更新 更多