添加 CDN 后,几乎所有 http API 都会返回 502 bad gateway 错误

添加 CDN 后,几乎所有 http API 都会返回 502 bad gateway 错误

我刚刚将我的网站添加到 CDN 提供商https://www.qiniu.com/en。然后我意识到几乎所有的 http API(https://www.funfun.ink/httpOnly..) 返回了 502 bad gateway 错误。此外,https://47.52.108.146/1/#/home不再起作用,它也返回了 502 错误网关错误。

CDN 提供商可能存在错误设置,有人知道可能是什么原因吗?

这是控制台https://www.funfun.ink/1/#/home

在此处输入图片描述

这是控制台https://www.funfun.ink/1/#/编辑/

在此处输入图片描述

这是 nginx 块

server {
    listen 80;
    server_name funfun.ink www.funfun.ink;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;

    server_name funfun.ink www.funfun.ink;

    ssl_certificate /etc/nginx/cert/1530230026231.pem;
    ssl_certificate_key /etc/nginx/cert/1530230026231.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/ssl/certs/dhparam.pem;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_session_timeout 1d;
    ssl_stapling on;
    ssl_stapling_verify on;
    add_header Strict-Transport-Security max-age=15768000;

    location ~* ^/\b(?!1|js|socket.io|monaco-editor|libs|dist|fonts|javascripts|formatter|ui|css|stylesheets|htmls|imgs|static|httpOnly|tmp|uploads)\w+\b/? {
        rewrite .* /1/#$request_uri redirect;
    }

    location ~* ^/1/\b(?!#|auth)\w+\b/? {
        rewrite ^/1/(.*[.]js)$ https://www.funfun.ink/dist/$1 redirect;
        rewrite ^/1/(.*[^.][^j][^s])$ https://www.funfun.ink/1/#/$1 redirect;
    }

    location = / {
        return 301 /home;
    }

    location ~ /.well-known {
        allow all;
    }

    location / {
        proxy_set_header    Host                $host;
        proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto   $scheme;
        proxy_set_header    Accept-Encoding     "";
        proxy_set_header    Proxy               "";
        proxy_pass          https://127.0.0.1:3000;

        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection "upgrade";
    }
}

答案1

proxy_pass httpS://127.0.0.1:3000...您确定可以通过 SSL 连接到本地主机(127.0.0.1)吗?

proxy_set_header X-Forwarded-Proto $scheme;- 在此行中,您已将方案转发到上游服务器。因此,应用程序(或上游服务器)应该足够智能,可以识别正在使用/转发的方案。

因此,proxy_pass指令应该是proxy_pass http://127.0.0.1:3000

相关内容