通过 nginx 代理站点导致空白页面

Proxying site via nginx results in blank page

我们已经使用 Wix.com 开发了我们网站的新版本。由于我们在 iOS 上使用深度链接,我们需要 place a text file in the website root. Turns out Wix doesn't support this currently although they are considering it.

"No problem," 我们认为。我们可以只使用 nginx 反向代理来提供 apple-app-site-association 文件并将其余流量代理到 Wix。我们使用以下 nginx 配置进行设置:

upstream wix {
    keepalive 100;
    server mgertner.wixsite.com:443;
}


server {
    listen              80;
    server_name         getcorkscrew.com;

    location / {
      proxy_http_version 1.1;
      proxy_pass https://wix/corkscrew-copy;
      proxy_pass_request_headers      on;
    }
}

server {
    listen              80;
    server_name         www.getcorkscrew.com;

    location / {
      proxy_http_version 1.1;
      proxy_pass https://mgertner.wixsite.com/corkscrew-copy;
      proxy_pass_request_headers      on;

    }
}

然而,当我们转到 www.getcorkscrew.com 时,我们只会得到一个空白的白页。显然 Wix 正在返回该页面,head 包含一堆脚本和其他内容,但 body 仅包含:

<body>
    <div id="SITE_CONTAINER"></div>
    <div comp="wysiwyg.viewer.components.WixAds" skin="wysiwyg.viewer.skins.wixadsskins.WixAdsWebSkin" id="wixFooter"></div>
    <script type="text/javascript">window.NREUM||(NREUM={});NREUM.info={"errorBeacon":"bam.nr-data.net","licenseKey":"c99d7f1ab0","agent":"","beacon":"bam.nr-data.net","applicationTime":9,"applicationID":"1963269,30200700","transactionName":"ZFAHNkNYXUBQVEUKXF0aNgdDT19WRRhVCkBDVBEBWVxB","queueTime":0}
    </script>
</body>

Wix 似乎以某种方式检测到代理的使用并阻止了正常的页面内容。但是当我们检查这个时,我们发送的 headers 与原始请求完全相同。

关于 Wix 如何知道我们正在使用代理以及我们如何解决这个问题有什么想法吗?

原来这是特定于 Wix 呈现网站的方式。他们将网站的 URL 嵌入到他们的 index.html 中,如果该网站是从另一个 URL 加载的,则该网站将不会呈现。我不认为他们是故意阻止的。在我看来,这只是渲染代码实现方式的副作用。

我们通过使用 nginx 子过滤器将 index.html 中嵌入的 URL 更改为我们正在代理的那个来修复此问题。现在可以正常使用了。