设置let加密后,网站重定向次数过多

时间:2017-04-11 21:02:05

标签: ssl nginx ssl-certificate cloudflare lets-encrypt

我已经设置了www.myapp.io,它连接到由nginx托管的MEAN-stack应用程序。它有效,现在,我想添加SSL。我已跟踪this linklet's encrypt保护。

但是,配置完成后,https://www.myapp.io无效:www.myapp.io redirected you too many times. ERR_TOO_MANY_REDIRECTS

以下是/etc/nginx/sites-enabled/myapp.io,有谁知道哪里出错了?

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

server {
    listen 443 ssl;

    server_name myapp.io www.myapp.io;

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

    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-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:EC$
    ssl_session_timeout 1d;
    ssl_stapling on;
    ssl_stapling_verify on;
    add_header Strict-Transport-Security max-age=15768000;

    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;
    }
}

(我没有放ssl_session_cache shared:SSL:50m;,因为ssl_session_cache shared:SSL:10m;已经/etc/nginx/nginx.conf了。)

添加ssl之前的配置文件,有效:

server {
    listen 80;
    server_name myopp.io *.myopp.io;

    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          http://127.0.0.1:3000;
    }
}

PS:该网站是通过cloudflare管理的,目前SSL上的clouldflare设置为Flexible,我不知道知道我是否需要改变它。

1 个答案:

答案 0 :(得分:0)

正如@ dave_thompson_085在评论中建议的那样,将Cloudflare中的super().__init__(*args)更改为Flexible会使Full无法访问...