HTTP to HTTPS on NGINX Django server

I'm setting up a server on AWS from a Django project and my Nginx gives an error when trying to switch from HTTP to HTTPS. See my file:

host = fantasy name

server {
    listen 80;
    server_name  host;
    return 301 https://host$request_uri;
    location = /favicon.ico { access_log off; log_not_found off; }
    location /staticfiles/ {alias  /home/ubuntu/Filmes/staticfiles/;}

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }

} 

Indeed when using the old domain over HTTP I am redirected to HTTPS but I get CONNECTION DENIED TO THIS DNS.

to Turn on HTTPS and access your site over HTTPS, you’ll need an SSL/TLS certificate that sits on your web server . you can get a certificate from a Certificate Authority (CA) like Let’s Encrypt which is free

Back to Top