I'm trying to set up a django project using SSL. I got it working without SSL but I'm clearly doing something wrong since https:// doesn't work and http:// just redirects to the main nginx site.
Here's my docker-compose file:
version: '3.2'
services:
immweb:
restart: always
build: .
command: gunicorn smn_imm.wsgi:application --bind 0.0.0.0:8000
volumes:
- /static:/static
- /var/log/imm:/var/log/imm
nginx:
build: nginx
depends_on:
- immweb
ports:
- "80:80"
- "443:443"
volumes:
- ./static/:/static/
- /etc/nginx/:/etc/nginx/
Here's my nginx.conf
server {
listen 80;
server_name smn-imm;
}
server {
listen 443;
ssl on;
server_name smn-imm;
ssl_certificate /etc/nginx/server.crt;
ssl_certificate_key /etc/nginx/server.key;
location / {
proxy_pass http://immweb:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
}
location /static/ {
autoindex on;
alias /static/;
}
}
Every site I look to for guidance does it a completely different way so I'm not sure what the "correct" way would be.