标头变量在生产中丢失 [英] header variables go missing in production

查看:126
本文介绍了标头变量在生产中丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行带有PhusionPassenger和NGINX的Rails 3.1.我正在通过一个简单的HttpClient(用于OS X的GrahpicalHttpClient)发送请求.我的代码需要标头中的令牌和ID来验证调用者的真实性.在开发模式下,这没问题,但是一旦我将其移入生产环境,标头变量就会丢失.什么都没有显示.

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.

这是代码:

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

如果任一变量为nil,则方法check_authentication_token返回nil.正如我所说,这在开发中工作正常,但是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?

推荐答案

Nginx默认认为请求标头中的下划线无效,随后将其删除,请参见

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.

这篇关于标头变量在生产中丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆