Nginx redirect request to HTTPS domain

1.5k views Asked by At

I have successfully installed Sentry in my server and I want to keep it safe with HTTPS. To do that I have configured NGINX but, I keep getting "The page isn't redirecting properly" error. I have tried official guide that sentry provides but no luck so far. Here is my NGINX configuration:

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

What am I missing?

2

There are 2 answers

0
mdegis On BEST ANSWER

These issues are most often associated with users of Cloudflare's Flexible SSL service. You can check whether you are using Cloudflare's SSL service in Full or Flexible mode by logging into your Cloudflare dashboard and clicking on the Crypto tab, then heading down the SSL setting:

cloudflare

If you use Cloudflare's Flexible SSL service and see mixed content issues or redirect loop errors, first ensure that there is no SSL certificate installed at your origin. If there is, then you shouldn't be using Flexible SSL and should instead set it to Full or Full(Strict).

0
RiDDi On

When "flexible" Cloudflare makes a request to your site:80 and gets redirect https