使用 Openresty / Nginx 反向代理保护 Cloudflare 网站

我想为我的 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;
}
点赞
用户5080543
用户5080543
proxy_pass https://nameofyourshop.myshopify.com
proxy_set_header Host nameofyourshop.myshopify.com

这可能会起作用

2020-07-11 15:10:19