Php 如何访问rails中与apache_请求_头相同的HTTP头?

Php 如何访问rails中与apache_请求_头相同的HTTP头?,php,ruby-on-rails,ruby,Php,Ruby On Rails,Ruby,我正在尝试访问Rails4中的一些自定义HTTP头 令人沮丧的部分。在使用phpapache\u request\u headers()函数时,我能够获得该自定义头,但在Rails 4中无法访问该头 到目前为止我试过的东西。 request.headers request.headers[“header\u name”] request.headers[“HTTP\u header\u name”] request.headers.env[“header\u name”] headers=Act

我正在尝试访问Rails4中的一些自定义HTTP头

令人沮丧的部分。在使用php
apache\u request\u headers()
函数时,我能够获得该自定义头,但在Rails 4中无法访问该头

到目前为止我试过的东西。

request.headers

request.headers[“header\u name”]

request.headers[“HTTP\u header\u name”]

request.headers.env[“header\u name”]

headers=ActionDispatch::Http::headers.new(env)

更多的方式,但无法访问标题。我是不是错过了什么

我试图访问此文件的位置

家庭控制器

class HomeController < ApplicationController
  def index
  end
end
class ApplicationController < ActionController::Base
    before_action :sso_handler, :only => [:index, :show]

    ...

    def sso_handler
       //all above commands i tried here.
    end
end 
class HomeController
应用控制器

class HomeController < ApplicationController
  def index
  end
end
class ApplicationController < ActionController::Base
    before_action :sso_handler, :only => [:index, :show]

    ...

    def sso_handler
       //all above commands i tried here.
    end
end 
class ApplicationController[:index,:show]
...
def sso_处理器
//以上所有命令我都试过了。
结束
结束

所以我不知道为什么我可以在php中访问头文件,为什么我不能在Rails 4中访问头文件。

最终找到了原因。这是nginx的问题。Nginx不允许头文件通过。需要指定nginx应该允许哪些头这样传递

在nginx.conf或可用站点下的站点配置文件中

location @app{
  ...
  uwsgi_param HTTP_HEADER_NAME $http_header_name;
  ...   
}

希望这能帮助某人:)

终于找到了原因。这是nginx的问题。Nginx不允许头文件通过。需要指定nginx应该允许哪些头这样传递

在nginx.conf或可用站点下的站点配置文件中

location @app{
  ...
  uwsgi_param HTTP_HEADER_NAME $http_header_name;
  ...   
}
希望这能帮助别人:)