Welcome! Log In Create A New Profile

Advanced

Problem when reconfiguring Nginx for SSL with self-signed certificate

September 04, 2018 02:30PM
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. Tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04#configure-nginx-to-proxy-pass-to-gunicorn

Now I modify the file /sites-available/LibrosWeb to allow SSL traffic with a self-signed certificate, since I do not have a domain.
Tutorial: https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-nginx-in-ubuntu-18-04
Result "Error 502 Bad Gateway".

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

server{
#Configuracion http

listen 80;
listen [::]:80;
server_name 15.15.15.15;

location = /favicon.ico { access_log off; log_not_found off; }
location /robots.txt {
alias /var/www/LibrosWeb/robots.txt ;
}
location /static/ {
root /home/gela/LibrosWeb;
}

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

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

server{
#Configuracion SSL

listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name 15.15.15.15;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;

location = /favicon.ico { access_log off; log_not_found off; }
location /robots.txt {
alias /var/www/LibrosWeb/robots.txt ;
}
location /static/ {
root /home/gela/LibrosWeb;
}

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

server{
#Configuracion http

listen 80;
listen [::]:80;
server_name 15.15.15.15;
return 302 https://15.15.15.15$request_uri;
}

UFW configured as:

80,443/tcp (Nginx Full) ALLOW IN Anywhere
80,443/tcp (Nginx Full (v6)) ALLOW IN Anywhere (v6)

The files /etc/nginx/snippets/self-signed.conf and /etc/nginx/snippets/ssl-params.conf are the same as those in the tutorial.

I've been testing configurations for two days and the most I could get is that I work halfway, that is, I can show the default page of django but not the one of my application, if I put the code like this:

server{
#Configuracion http

listen 80;
listen [::]:80;
server_name 15.15.15.15;
return 302 https://15.15.15.15$request_uri;

location = /favicon.ico { access_log off; log_not_found off; }
location /robots.txt {
alias /var/www/LibrosWeb/robots.txt ;
}
location /static/ {
root /home/gela/LibrosWeb;
}
}

server{
#Configuracion SSL

listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name 15.15.15.15;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;

location / {
include proxy_params;
proxy_pass https://unix:/run/gunicorn.sock;
}
}
What is wrong, or what is missing?
Subject Author Posted

Problem when reconfiguring Nginx for SSL with self-signed certificate

Frank_Mascarell September 04, 2018 02:30PM

Re: Problem when reconfiguring Nginx for SSL with self-signed certificate

Francis Daly September 05, 2018 11:52AM

Re: Problem when reconfiguring Nginx for SSL with self-signed certificate

Frank_Mascarell September 05, 2018 04:49PM

Re: Problem when reconfiguring Nginx for SSL with self-signed certificate

Francis Daly September 05, 2018 05:40PM

Re: Problem when reconfiguring Nginx for SSL with self-signed certificate

Frank_Mascarell September 05, 2018 06:51PM

Re: Problem when reconfiguring Nginx for SSL with self-signed certificate

Francis Daly September 06, 2018 03:02AM

Re: Problem when reconfiguring Nginx for SSL with self-signed certificate

Frank_Mascarell September 08, 2018 11:25PM

Re: Problem when reconfiguring Nginx for SSL with self-signed certificate

Francis Daly September 10, 2018 08:00AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 85
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready