I have a web backend implemented in Django and running on Gunicorn. Plus, I also have a Vue.js app that uses this backend. I want to run both of them on nginx and also do HTTPS configs.
This is how my "/etc/nginx/nginx.conf" file looks like:
...
server {
server_name .website.com;
listen 80;
return 307 https://$host$request_uri;
}
server {
location / {
proxy_set_header Host $host;
proxy_pass http://localhost:8080; # where the Django app over gunicorn is running
}
location /static {
root /code/frontend/dist/; # static frontend code created with vite on vue.js
autoindex on;
index index.html;
try_files $uri $uri/ /index.html;
}
# ssl configs
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/website.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/website.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
}
Both of them, Django and Vue.js part, are hosted in a single Docker container. 80 and 8080 ports of this container is mapped to 80 and 8080 ports of the host PC.
443, 8080 and 80 ports are open on the machine for inbound connections. Sending a post request to http://website.com:8080/bla do returns correct values, meaning that backend seems to be working but on http only and not on https.
Still when I go to the "website.com", I receive "This site can't be reached" error. Where am I doing wrong exactly and how can I run both on nginx and both over ssl/https?