安装 SSL 证书后,我收到错误“加载无法遵循超过 20 个重定向”

安装 SSL 证书后,我收到错误“加载无法遵循超过 20 个重定向”

这是我的配置文件:


server {
        server_name songreccs.com;


        location /static {
                root /home/user/sonreccs/flaskrec/;
        }

        location / {
                proxy_pass http://localhost:8000;
                include /etc/nginx/proxy_params;
                proxy_redirect off;
        }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/songreccs.com/fullchain.pem; # manage>
    ssl_certificate_key /etc/letsencrypt/live/songreccs.com/privkey.pem; # mana>
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
    if ($host = songreccs.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80;
        server_name songreccs.com;
    return 404; # managed by Certbot


}

server {
    if ($host = www.songreccs.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
        server_name www.songreccs.com;
    return 404; # managed by Certbot



    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/songreccs.com/fullchain.pem; # manage>
    ssl_certificate_key /etc/letsencrypt/live/songreccs.com/privkey.pem; # mana>
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}



在安装证书之前,它一直运行正常。我使用 Nginx 作为 Gunicorn 的反向代理。Gunicorn 在后台运行一个 flask 应用程序。

答案1

这是一个我不知道自己在做什么的问题。

配置文件有一个服务器块,它监听端口 443 并重定向到端口 443,这很可能就是问题所在。

相关内容