Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

header variables go missing in production

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?

like image 392
germs12 Avatar asked Dec 06 '22 21:12

germs12


1 Answers

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.

like image 178
jqr Avatar answered Dec 11 '22 09:12

jqr