通过nginx代理网站会导致空白页



我们使用 Wix.com 来开发我们网站的新版本。由于我们在iOS上使用深度链接,因此我们需要在网站根目录中放置一个文本文件。事实证明 Wix 目前不支持此功能,尽管他们正在考虑这样做。

"没问题,"我们想。我们可以使用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>
    <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以某种方式检测到代理的使用并阻止了正常的页面内容。但是当我们检查这一点时,我们发送的标头与原始请求完全相同。

关于Wix如何知道我们正在使用代理以及如何解决此问题的任何想法?

事实证明,

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

我们通过使用 nginx 子过滤器将嵌入在index.html中的 URL 更改为我们正在代理的 URL 来解决此问题。现在它工作正常。

最新更新