我有一个Ubuntu 14.04服务器,我有一个在这台服务器上运行localhost:3000的流星应用程序.我的服务器的公共FQDN是sub.example.com.流星应用程序使用Google OAuth 2.0,我在Google Api控制台中配置了以下内容:
URI REDIRECTION
http://sub.example.com/_oauth/google
http://sub.example.com/_oauth/google?close
ORIGInes JAVASCRIPT
http://sub.example.com
server {
listen 80 default_server;
server_name sub.example.com www.sub.example.com;
location / {
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:3000;
}
}
代理工作,我去sub.example.com时可以访问我的meteor应用程序.但是当我在这个应用程序中尝试使用Google OAuth 2.0时,会弹出一个弹出窗口,我会得到:
Error: redirect_uri_mismatch
The redirect URI in the request: http://localhost:3000/_oauth/google?close did not match a registered redirect URI.
我显然错过了一些东西.
解决方法:
您应该重写后端发送到http://wiki.nginx.org/HttpProxyModule#proxy_redirect中描述的Nginx的Location头,所以:
proxy_redirect http://localhost:3000/_oauth/google http://sub.example.com/_oauth/google;
另一个适用于弹出式登录的选项是在启动时为Meteor设置ROOT_URL环境变量,如下所示:
ROOT_URL="http://sub.example.com" PORT=3000 node main.js
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。