【问题标题】:Open remote Meteor DDP Connection behind reverse proxy在反向代理后面打开远程 Meteor DDP 连接
【发布时间】:2015-02-06 12:17:26
【问题描述】:

我正在努力使用 Meteor 的 DDP.connect() 打开从 https://siteA.comhttps://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 配置设置将此请求列入白名单?任何帮助表示赞赏。

【问题讨论】:

    标签: nginx meteor


    【解决方案1】:

    经过一些初步的谷歌搜索后,这里有一个小提示: Mixed Content: The page at 'XYZ' was loaded over HTTPS, but requested an insecure over https

    ...尽管它谈论的是样式表而不是 XMLHttpRequest,但它肯定是相关的

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-08
      • 2017-04-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多