Introduces a production Docker Compose stack that places nginx in front of gunicorn. nginx serves the frontend SPA and Django static files directly, and proxies all backend routes (/api, /admin, /healthz, etc.) to the Django container. SECURE_SSL_REDIRECT is now env-configurable so plain-HTTP nginx deployments work without separate settings files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
37 lines
965 B
Nginx Configuration File
37 lines
965 B
Nginx Configuration File
upstream django {
|
|
server web:8000;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
client_max_body_size 100m;
|
|
|
|
# Django static files — served directly; never reaches gunicorn
|
|
location /static/ {
|
|
alias /app/staticfiles/;
|
|
expires 30d;
|
|
add_header Cache-Control "public, immutable";
|
|
gzip_static on;
|
|
}
|
|
|
|
# Backend routes — proxied to gunicorn
|
|
location ~ ^/(admin|api|healthz|metrics|oidc|training|v1)(/|$) {
|
|
proxy_pass http://django;
|
|
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_set_header X-Forwarded-Proto $scheme;
|
|
proxy_redirect off;
|
|
proxy_read_timeout 60s;
|
|
}
|
|
|
|
# Frontend SPA — serve index.html for any unmatched path
|
|
location / {
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
}
|