docker nginx tls設定 - jenhaoyang/backend_blog GitHub Wiki

範例:

upstream django_app {
    server web:443;
}

server {

    listen 443 ssl;
    
    location /static {
        alias /workspace/static; # your Django project's static files - amend as required
    }

    location / {
        proxy_pass https://django_app;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
    }

    charset     utf-8;
    client_max_body_size 500M;

    ssl_certificate /etc/nginx/conf.d/certs/example.com.pem;
    ssl_certificate_key /etc/nginx/conf.d/certs/example.com.key;
    #root /usr/share/nginx/html;

    add_header Strict-Transport-Security "max-age=31536000" always;
}

參考:
https://medium.com/@cloudcleric/deploying-a-django-application-in-docker-with-nginx-beeed45bebb8
https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/
https://github.com/charleshb417/blog-django-docker