nginx重定向循环运行反向代理子目录

nginx重定向循环运行反向代理子目录

我正在尝试在 nginx 服务器上沿着 express 应用程序安装一个 ghost 博客。

博客应该在 /blog 子目录中运行,express 将处理 /* 上的所有其他路由

现在,安装似乎正在工作,因为幽灵进程获得了请求,但我遇到了重定向循环。

怎么了?

    server {
        listen 80;
        server_name url.io www.url.io;
        return 301 https://url.io$request_uri;
    }

    server {
        listen 443 ssl;
        server_name www.url.io;
        return 301 https://url.io$request_uri;
            ssl_certificate /etc/letsencrypt/live/url.io/fullchain.pem;
            ssl_certificate_key /etc/letsencrypt/live/url.io/privkey.pem;
    }

    server {
            listen 443 ssl;
            server_name url.io;

            ssl_certificate /etc/letsencrypt/live/url.io/fullchain.pem;
            ssl_certificate_key /etc/letsencrypt/live/url.io/privkey.pem;

            ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
            ssl_prefer_server_ciphers on;
            ssl_dhparam /etc/ssl/certs/dhparam.pem;
            ssl_ciphers 'STRING'
            ssl_session_timeout 1d;
            ssl_session_cache shared:SSL:50m;
            ssl_stapling on;
            ssl_stapling_verify on;
            add_header Strict-Transport-Security max-age=15768000;

            location / {
                    proxy_pass http://127.0.0.1:8080;
                    proxy_http_version 1.1;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection 'upgrade';
                    proxy_set_header Host $host;
                    proxy_cache_bypass $http_upgrade;
                    try_files $uri $uri/ /index.html =404;
            }

            location /blog {
                    proxy_pass http://127.0.0.1:2368;
                    proxy_http_version 1.1;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection 'upgrade';
                    proxy_set_header Host $host;
                    proxy_cache_bypass $http_upgrade;
            }

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

答案1

好的,我在 ghost 配置中找到了它:

问题是我在生产中使用了 https:

 production: {
    url: 'https://url.io/blog'
}

将 url 更改为 http 就成功了...很奇怪但却是事实。

相关内容