通过Nginx代理站点导致空白页 [英] Proxying site via nginx results in blank page

查看:2075
本文介绍了通过Nginx代理站点导致空白页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

We have used Wix.com to develop a new version of our website. Since we are using deep linking on iOS, we need to place a text file in the website root. Turns out Wix doesn't support this currently although they are considering it.

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

"No problem," we thought. We can just use an nginx reverse proxy to serve up the apple-app-site-association file and proxy the rest of the traffic to Wix. We set this up with the following nginx config:

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包含一堆脚本和其他内容,但正文仅包含:

However, when we go to www.getcorkscrew.com, we just get a blank white page back. Clearly the page is being returned by Wix, and the head contains a bunch of scripts and other stuff, but the body just contains:

<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似乎正在以某种方式检测代理的使用并阻止正常的页面内容.但是,当我们选中此选项时,我们将通过与原始请求完全相同的标头发送邮件.

It seems that Wix is somehow detecting the use of a proxy and blocking the normal page content. But when we checked this, we are sending over exactly the same headers as the original request.

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

Any ideas about how Wix knows we are using a proxy and how we can get around this?

推荐答案

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

Turns out this is specific to how Wix renders the site. They embed the URL of the site in their index.html and the site won't render if it is loaded from another URL. I don't think they are blocking this on purpose. To me it just looks like a side effect of how the rendering code was implemented.

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

We fixed this by using an nginx subfilter to change the URL embedded in index.html to the one we are proxying from. Now it works fine.

这篇关于通过Nginx代理站点导致空白页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆