Nginx 代理 Wix 网站在浏览器中仅显示空白页或未找到

Nginx 代理 Wix 网站在浏览器中仅显示空白页或未找到

我们正在尝试代理 Wix 网站(https://mgertner.wixsite.com/corkscrew-copy) 通过 Nginx 代理。我们尝试了大部分标头和 cookie 设置,但仍然出现空白页或 wix 错误。我们还尝试了 SSL 代理,但没有任何效果。getcorkscrew.com 返回 Wix 未找到页面,www.getcorkscrew.com 仅返回空白页。这是 nginx 配置(请注意,在 getcorkscrew.com 的情况下我们使用上游,而在 wwww.getcorkscrew.com 的情况下则不使用)。

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;

    }
}

Wix 网站设置为在 www.getcorkscrew.com 上回答问题。(因此 Wix 内部路由可能存在问题)。所有标头和 cookie 都应原封不动地传递。我们甚至使用 phpinfo() 启动了一个 PHP 服务器,以检查 nginx 真正更改了什么,唯一不同的是 IP 地址(显然)和 HTTP 版本(我们随后在配置中对其进行了更改)。

谢谢,Jan

答案1

我有一个使用 nginx 代理 wix 网站的工作配置:

server {
    listen       80;
    server_name  example.com;

    location / {
        gzip off;
        proxy_set_header Accept-Encoding "";
        add_header Host mysite.wixsite.com;
        proxy_pass_request_headers      on;
        proxy_http_version 1.1;
        proxy_pass https://mysite.wixsite.com/mywixsite;
        sub_filter_types application/javascript application/x-javascript text/javascript;
            sub_filter 'var publicModel = {"domain":"wixsite.com","externalBaseUrl":"https:\/\/mysite.wixsite.com\/mywixsite","unicodeExternalBaseUrl":"https:\/\/mysite.wixsite.com\/mywixsite"}' 'var publicModel = {"domain":"example.com","externalBaseUrl":"http:\/\/example.com","unicodeExternalBaseUrl":"http:\/\/example.com"}';
            sub_filter_once off;
        }
    }
}

example.com你的 在哪里getcorkscrew.comhttps://mysite.wixsite.com/mywixsite你的 在哪里https://mgertner.wixsite.com/corkscrew-copy

另请检查这个 StackOverflow 问题及其评论。

答案2

从 2023 年开始更新。Wix 内部似乎已发生改变,因此以前的 sub_filters 不再起作用。

使用以下配置即可工作。

请注意,此具体配置是使用 Premium 帐户测试的,并且没有将域名绑定到网站。将域名连接到 Wix 网站后,请添加相应的过滤器。

location ~ ^/(.*)$ {
    gzip off;
    proxy_ssl_server_name on;
    proxy_set_header Accept-Encoding "";
    proxy_set_header X-Forwarded-Host "";
    proxy_set_header X-Forwarded-For "";
    proxy_set_header Referer https://username.wixsite.com/sitename;
    add_header Host username.wixsite.com;
    proxy_pass_request_headers on;
    proxy_http_version 1.1;

    resolver 8.8.8.8;
    proxy_pass https://username.wixsite.com/sitename/$1$is_args$args;

    sub_filter_types text/html application/javascript application/x-javascript text/javascript;
    sub_filter "https%3A%2F%2Fusername.wixsite.com%2Ffinsimco" "https%3A%2F%2F$http_host";
    sub_filter "https%3A%2F%2Fusername.wixsite.com" "https%3A%2F%2F$http_host";
    sub_filter https://username.wixsite.com/sitename https://$http_host;
    sub_filter https://username.wixsite.com https://$http_host;
    sub_filter "https:\/\/username.wixsite.com\/sitename" "https:\/\/$http_host";
    sub_filter "https:\/\/username.wixsite.com" "https:\/\/$http_host";
    sub_filter_once off;
}

相关内容