具有Openresty / Nginx反向代理的受Cloudflare保护的网站

时间:2019-12-27 13:42:50

标签: nginx shopify reverse-proxy cloudflare openresty

我想为我的shopify网站使用Openresty(Nginx)构建反向代理,但是在Openresty中设置.conf文件并启动服务器之后。它显示了Cloudflare的403错误。请让我知道如何解决。谢谢。

流程: 客户端>反向代理> Cloudflare>真实站点

以下是我的朋友。

 location ~ ^/  {
    # proxy_connect_timeout       10;
    # proxy_send_timeout          30;
    # proxy_read_timeout          30;
    proxy_set_header Host www.myshopdomain.com;
      proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
       proxy_set_header X-Real-IP  $remote_addr;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Connection "upgrade";
    proxy_read_timeout 86400;
    proxy_redirect off;

 proxy_pass                  https://www.myshopdomain.com$request_uri;
# https://serverfault.com/questions/824140/nginx-log-request-and-response-api-proxy/824291
# log_format upstream_logging '[$time_local] $remote_addr - $remote_user - $server_name to: $upstream_addr: $request upstream_response_time $upstream_response_time msec $msec request_time $request_time';


}
# shopify urls
# ------------
location ~ ^/(collections|cart|products|shopify|pages|blogs|checkout|admin)/? {
    proxy_pass https://www.myshopdomain.com;
 proxy_set_header Host www.myshopdomain.com;
    client_max_body_size    10m;
    client_body_buffer_size     128k;
    proxy_connect_timeout 90;
}

1 个答案:

答案 0 :(得分:0)

proxy_pass https://nameofyourshop.myshopify.com
proxy_set_header Host nameofyourshop.myshopify.com 

这可以解决问题