2
代理所以我使用OmniAuth與GitHub的策略來處理用戶身份驗證爲我的項目。直接訪問Rails服務器時,一切正常。我最近設置了Nginx來處理我的開發前端和後端服務器之間的代理。現在,當我訪問/auth/github
,OmniAuth觸發關閉請求GitHub上,但隨後失敗的回調:CallbackError與OmniAuth當通過Nginx的
Started GET "/auth/github/callback?error=redirect_uri_mismatch" for 127.0.0.1 at 2014-01-22 11:54:35 -0800
I, [2014-01-22T11:54:35.365773 #13656] INFO -- omniauth: (github) Callback phase initiated.
E, [2014-01-22T11:54:35.366091 #13656] ERROR -- omniauth: (github) Authentication failure! redirect_uri_mismatch: OmniAuth::Strategies::OAuth2::CallbackError, redirect_uri_mismatch
E, [2014-01-22T11:54:35.366149 #13656] ERROR -- omniauth: (github) Authentication failure! invalid_credentials: OmniAuth::Strategies::OAuth2::CallbackError, redirect_uri_mismatch
我在我的應用程序的GitHub上設置回調URL設置爲正確的網址,這顯然使得請求正確,只需要這個神祕的redirect_uri_mismatch
。
這裏是我的Nginx服務器塊:
server {
listen 8080;
server_name localhost;
location/{
proxy_pass http://localhost:9000;
}
location /api/ {
proxy_pass http://localhost:3000;
}
location /auth/ {
proxy_pass http://localhost:3000;
}
}
我實在看不出有什麼好的理由,這不應該工作,雖然我是一個相對的小白來配置Nginx的。