Home:ALL Converter>django+nginx+gunicorn issues with Cerbot to turn into HTTPS

django+nginx+gunicorn issues with Cerbot to turn into HTTPS

Ask Time:2022-01-23T22:31:29         Author:Baptiste ZLOCH

Json Formatter

I am currently deploying my django app on a server AWS Lightsail Debian 10.8. It's working fine with http. So I wnated to turn my app into HTTPS and getting an SSL certificate. I followed 2 tutorials about it :

Once all these steps done nothing works anymore even in HTTP, the site isn't accessible... Here is the config file in /etc/nginx/sites-available.

 server {
  server_name www.zlochteam.com;

 location / {
        include proxy_params;
        proxy_pass http://localhost:8000/;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/www.zlochteam.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/www.zlochteam.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


 server {
    if ($host = www.zlochteam.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

  listen 80;
  server_name www.zlochteam.com;
    return 404; # managed by Certbot


I wanted to know if someone has ecountered the same issue and how he solved it.

Thanks !

Author:Baptiste ZLOCH,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/70823067/djangonginxgunicorn-issues-with-cerbot-to-turn-into-https
raphael :

Before you run the commands in certbot, make sure you have the following in your Nginx:\nserver {\n listen 80;\n server_name www.zlochteam.com;\n listen [::]:80;\n ...\n\nSeems like certbot now requires the ipv6 as well.",
Aleksey Vaganov :

Http has break because the certbot added the redirect return 301 https://$host$request_uri;\nYou should test config by command nginx -t and then reload config nginx -s reload.",