Google OAuth2 uri_mismatch在nginx反向代理后面

问题描述:

我在尝试使用nginx反向代理和ssl的新服务器配置,但似乎打破了我的Google OAuth2。我正在使用节点v6.2.2,pm2来管理nodejs,并使用nginx作为ssl和反向代理。Google OAuth2 uri_mismatch在nginx反向代理后面

我的Nginx服务器块的样子:

server { 
    listen 80; 
    server_name _; 
    return 301 https://$host$request_uri; 
} 

server { 
    listen 443; 
    ssl on; 
    include snippets/ssl-example.com.conf; 
    include snippets/ssl-params.conf; 
    server_name example.com; 
    location/{ 
      proxy_pass http://localhost:3001; 
      proxy_http_version 1.1; 
      proxy_set_header Upgrade $http_upgrade; 
      proxy_set_header Connection 'upgrade'; 
      proxy_set_header Host $host; 
      proxy_cache_bypass $http_upgrade; 
    } 
} 

当运行在我的笔记本电脑我可以在使用passportjs'谷歌的策略没有问题,登陆服务器的NodeJS,但只要我在反向代理后面运行相同的代码,我会得到一个redirect_uri_mismatch。我试过硬编码回调URLhttp://example.com/auth/oauthCallbackhttps://example.com/auth/oauthCallback,并已将这些变体的所有变体添加到OAuth客户端ID。我试过对我的服务器模块进行小小的改动,并且无法取得进展,所以我就是这样。

下一步的任何想法?

原来Google的OAuth2似乎无法识别.xyz域名