Facebook 身份验证在 rails 3.2.3 上引发错误
Facebook authentication is raising an error on rails 3.2.3
我设置了一个 rails 应用程序(3.2.3 [设计 3.4.1,omniauth facebook 2.0.0,omniauth 1.2.2])以将 facebook 用作authenticator 并且我在尝试登录时遇到了这个问题。问题是,它甚至没有到达我的代码(控制器)。你有什么想法吗?
奇怪的是,当我在主机上设置 127.0.0.1 mydomain.com
并浏览到 mydomain.com:3000
时,它起作用了!虽然在本地我使用 http
而不是 https
像生产。
Started GET "/users/auth/facebook" for x.x.x.x at 2015-02-12 00:45:05 +0000
Started GET "/users/auth/facebook/callback?code=xxxx" for 127.0.0.1 at 2015-02-12 00:45:05 +0000
URI::InvalidURIError (the scheme http does not accept registry part: app_server (or bad hostname?)):
/home/deployer/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/uri/generic.rb:214:in `initialize'
/home/deployer/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/uri/http.rb:84:in `initialize'
/home/deployer/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/uri/common.rb:214:in `new'
/home/deployer/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/uri/common.rb:214:in `parse'
/home/deployer/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/uri/common.rb:747:in `parse'
omniauth (1.2.2) lib/omniauth/strategy.rb:416:in `full_host'
原来是nginx代理的问题,我忘记转发给定位置的Host
header。我刚刚设置了 header 主机,一切正常。
proxy_set_header Host 'example.com';
我设置了一个 rails 应用程序(3.2.3 [设计 3.4.1,omniauth facebook 2.0.0,omniauth 1.2.2])以将 facebook 用作authenticator 并且我在尝试登录时遇到了这个问题。问题是,它甚至没有到达我的代码(控制器)。你有什么想法吗?
奇怪的是,当我在主机上设置 127.0.0.1 mydomain.com
并浏览到 mydomain.com:3000
时,它起作用了!虽然在本地我使用 http
而不是 https
像生产。
Started GET "/users/auth/facebook" for x.x.x.x at 2015-02-12 00:45:05 +0000
Started GET "/users/auth/facebook/callback?code=xxxx" for 127.0.0.1 at 2015-02-12 00:45:05 +0000
URI::InvalidURIError (the scheme http does not accept registry part: app_server (or bad hostname?)):
/home/deployer/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/uri/generic.rb:214:in `initialize'
/home/deployer/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/uri/http.rb:84:in `initialize'
/home/deployer/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/uri/common.rb:214:in `new'
/home/deployer/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/uri/common.rb:214:in `parse'
/home/deployer/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/uri/common.rb:747:in `parse'
omniauth (1.2.2) lib/omniauth/strategy.rb:416:in `full_host'
原来是nginx代理的问题,我忘记转发给定位置的Host
header。我刚刚设置了 header 主机,一切正常。
proxy_set_header Host 'example.com';