【发布时间】:2015-02-06 12:17:26
【问题描述】:
我正在努力使用 Meteor 的 DDP.connect() 打开从 https://siteA.com 到 https://siteB.com 的连接,其中两台服务器都位于从 http 转发到 https 的 nginx 反向代理后面。
开发过程中一切正常。在生产中,当我在 siteA 的控制台中运行 DDP.connect('siteB.com') 时,我收到:
Mixed Content: The page at 'https://siteA.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://siteB.com/sockjs/info?cb=zw6j36l90y'. This request has been blocked; the content must be served over HTTPS.
在我当前为 siteB 配置的 nginx 中,我有以下内容(在相关部分,如果需要更多,请使用 lmk):
server {
listen 80 default_server;
location / {
rewrite ^ https://$server_name$request_uri? permanent;
}
}
server {
listen 443 ssl spdy;
add_header Access-Control-Allow-Origin 'https://siteA.com';
proxy_pass http://localhost:3000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Nginx-Proxy true;
proxy_redirect off;
}
我知道它抱怨请求在 http 端点 (http://localhost:3000) 中终止,但我不知道该怎么办。
如果我将 siteB 的 nginx 配置更改为 proxy_pass https://localhost:3000,则会生成 502 Bad Gateway。
我在 siteB 上尝试过使用和不使用 Meteor 的 force-ssl 包。
这两个站点都不包含 Meteor 的 browser-policy 包 - 根据我的阅读,没有包的默认设置应该允许我按原样连接到任何地方。
我也尝试了DDP.connect("ws://siteB.com");,但这导致:
XMLHttpRequest cannot load ws://siteB.com/sockjs/info?cb=9lahswe7_9. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
我应该在不同的端口上监听吗?是否有 nginx 配置设置将此请求列入白名单?任何帮助表示赞赏。
【问题讨论】: