Question

Receiving 503 on Nginx after setting Cloudflare's Origin Certificate

Connected Tutorial
This question is a follow-up to this tutorial:

I have a Django app running with Nginx + Gunicorn. Before, I had a Let’s Encrypt Certificate and Cloudflare SSL encryption mode as Full. After deleting the Let’s Encrypt Cert and modifying everything on my Nginx server I followed this tutorial. Now every request returns 503.

Nginx /sites-enabled/:

server {
    listen 80;
    listen [::]:80;
    server_name my-site.com www.my-site.com;
    return 302 https://$server_name$request_uri;
}

server {
    # SSL configuration

    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    ssl        on;
    ssl_certificate         /etc/ssl/cert.pem;
    ssl_certificate_key     /etc/ssl/key.pem;
    ssl_client_certificate  /etc/ssl/cloudflare.crt;
    ssl_verify_client on;


    server_name my-site.com www.my-site.com;

    location = /favicon.ico {
        access_log off;
        log_not_found off;
    }

    location /static/ {
        root /home/sammy/myproject/app;
    }

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

Every status shows that everything is running and active.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Found the solution to this nightmare: Instead of being a problem with Cloudflare’s SSL - altough my first thoughts were related to it because I changed the LetsEncrypt SSL certificate first - it was, indeed, a problem with how Nginx connects to Gunicorn. The server’s Nginx config is alright but the Gunicorn service was located in another folder, not in the one written in the OP.

Hi there,

What I could suggest is checking your Nginx error log so you could see the actual error rather than the generic 503 error:

  1. tail -100 /var/log/nginx/error.log

Feel free to share the error here as well so I could try to advise you further.

Regards, Bobby