Nginx 重定向请求到 HTTPS 域

Nginx redirect request to HTTPS domain

我已经在我的服务器上成功安装了 Sentry,我想使用 HTTPS 来保证它的安全。为此,我配置了 NGINX,但我不断收到 "The page isn't redirecting properly" 错误。我已经尝试过哨兵提供的官方指南,但到目前为止没有运气。这是我的 NGINX 配置:

server {
    listen 443;

    ssl on;
    server_name sentry.test.co;
    ssl_certificate       /etc/letsencrypt/live/sentry.test.co/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/sentry.test.co/privkey.pem;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL;

    location / {
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Proto $scheme;
    proxy_intercept_errors  on;
    proxy_pass              http://localhost:9000;
    }
}

server {
    listen 80;
    server_name sentry.test.co;
    return 301 https://sentry.test.co$request_uri;
}

我错过了什么?

这些问题通常与 Cloudflare 的灵活 SSL 服务的用户有关。您可以通过登录 Cloudflare 仪表板并单击“加密”选项卡,然后点击 SSL 设置来检查您是在完全模式还是灵活模式下使用 Cloudflare 的 SSL 服务:

如果您使用 Cloudflare 的灵活 SSL 服务并看到混合内容问题或重定向循环错误,请首先确保您的来源没有安装 SSL 证书。如果存在,则您不应使用 Flexible SSL,而应将其设置为 Full 或 Full(Strict)。

当 "flexible" Cloudflare 向您的 site:80 发出请求并获得重定向 https