我想實現一個簡單的谷歌的OAuth使用本指南以下passport.js我Express.js的應用程序(只需更換facebook
與google
)https://github.com/passport/express-4.x-facebook-example/blob/master/server.jsPassport.js表示谷歌的OAuth 502錯誤的網關上的nginx
當我在本地嘗試,事情似乎運作良好。當我將其部署到我的Ubuntu生產服務器時,在從Google重定向回調到/login/google/return
端點期間出現502 Bad Gateway
錯誤。
app.get('/login/google/return',
passport.authenticate('google', { failureRedirect: '/login' }),
function(req, res) {
res.redirect('/');
});
如果我註釋掉行passport.authenticate('google', {..})
,那麼錯誤就會消失。在檢查Nginx的錯誤日誌,我看到這個錯誤
upstream sent too big header while reading response header from upstream
下面是nginx的服務器配置塊:
location /auth/ {
proxy_pass http://0.0.0.0:3000/;
}
這意味着我需要登錄轉到https://example.com/auth/login/google
,被重定向到https://example.com/auth/login/google/return?code=4/adasfdafdsfd#
谷歌,然後發生502錯誤。
我已經嘗試在我的OS X開發機器上設置一個類似的nginx環境,但問題不會發生在那裏。
我也試圖添加以下nginx的塊配置,但似乎並沒有幫助任何
proxy_buffers 8 16k;
我在我束手無策爲如何調試/解決這個問題。任何人的建議將不勝感激。這裏是我的項目到目前爲止的鏈接https://github.com/tnguyen14/auth/blob/master/index.js
爲了確保我理解正確,如果您訪問https://example.com/auth/login/google/,您將獲得您的登錄頁面,但是如果您轉到https://example.com/auth/登錄/谷歌/返回你得到502.你真的試着去https://example.com/auth/login/google/return?只需在地址欄中輸入該地址,然後按回車鍵,你會得到502嗎? – Molda
看看這個http://stackoverflow.com/q/23844761/3284355 – Molda
@Molda如果我直接去'/ login/google/return',它可以正常工作,因爲它會重定向到Google的帳戶選擇器頁面。只有當Google使用502發生的代碼重定向到'/ login/google/return'時。 我不認爲你鏈接的答案是非常相關的,因爲我沒有使用fastcgi。 –