header variables go missing in production

2019-04-10 03:06发布

I'm running Rails 3.1 with PhusionPassenger and NGINX in the back. I'm sending requests via a simple HttpClient (GrahpicalHttpClient for OS X). My code expects a token and an ID in the header to verify the authenticity of the caller. In developement mode this is no problem, but once I move it into production the header variables go missing. Nothing is displayed.

Here is the code:

@caller = Person.check_authentication_token(request.headers['person_id'], request.headers['authentication_token'])

The method check_authentication_token returns nil if either variable is nil. As I said, this works fine in development but the request.headers['person_id'] and request.headers['authentication_token'] are both nil in production. Has anyone else seen this issue before?

1条回答
祖国的老花朵
2楼-- · 2019-04-10 03:32

Nginx defaults to considering underscores in request headers invalid and subsequently removes them, see http://wiki.nginx.org/HttpCoreModule#underscores_in_headers for how to fix this.

查看更多
登录 后发表回答