Cloudflare and Nginx

Hello, when i use this Nginx config for my nginx server, i get this error on my browser when i visit my website (polido.pt): ERR_TOO_MANY_REDIRECTS

server {
    listen 80;
    server_name polido.pt www.polido.pt;

    location / {
        rewrite ^ https://$host$request_uri permanent;
    }
}

server {
    listen 443;
    server_name polido.pt www.polido.pt;

    location / {
        alias /;  # The root directory
        index pingu.mp4;
    }
}


But with this config file for my Nginx server (default one) everything works ok and the website loads:

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
}
Was this page helpful?