我有一个使用Devise设置的身份验证系统。
我可以在开发模式下成功登录,但我无法在登台/制作环境中登录具有有效凭据的用户。
会话存储能否成为原因?
这就是我在config / initializers / session_store.rb中的内容:
# Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_pigo_session'
我还在config / intitializers / devise.rb
中添加了config.http_authenticatable = false
我的staging.log文件如下所示:
I, [2015-06-10T16:57:20.325304 #3577] INFO -- : Started GET "/" for 69.59.28.19 at 2015-06-10 16:57:20 +0400
I, [2015-06-10T16:57:20.327106 #3577] INFO -- : Processing by OffersController#index as HTML
I, [2015-06-10T16:57:20.328034 #3577] INFO -- : Filter chain halted as #<Proc:0x007fad7d18c5b8@/home/deploy/apps/pigo/shared/bundle/ruby/2.1.0/gems/actionpack-4.1.4/lib/action_controller/metal/http_authentication.rb:71> rendered or redirected
I, [2015-06-10T16:57:20.328232 #3577] INFO -- : Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)
答案 0 :(得分:0)
如果这可以帮助任何人,我最近也遇到了类似的问题。问题出在nginx配置(在我的生产环境中用作反向代理)。
这是我为解决此问题而进行的更改:
upstream puma {
server localhost:3000;
}
server {
# ...
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; # <== added this line
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma;
}
}