Problem when reconfiguring Nginx for SSL with self-signed certificate

Francis Daly francis at
Wed Sep 5 15:51:22 UTC 2018

On Tue, Sep 04, 2018 at 02:30:18PM -0400, Frank_Mascarell wrote:

Hi there,

> I have a VPS on Digital Ocean with Ubuntu 18.04, Nginx, Gunicorn, Django,
> and a test web application, all configured (ufw) to work with http: 80.
> Everything works perfectly. 

> Now I modify the file /sites-available/LibrosWeb to allow SSL traffic with a
> self-signed certificate, since I do not have a domain. 

> Result "Error 502 Bad Gateway".

> This is the initial code that works well with http: 80:

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

> And this is the code to allow SSL (error 502):

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

Unless you changed something on the gunicorn side, you almost certainly
want to use http, not https, to the socket.

So change the proxy_pass back to what it was.

The first tutorial you linked to does include some troubleshooting
tips. If you still have a problem, including the output from the nginx
parts of those will probably help the next person.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list