# nginx.conf user nginx; worker_processes auto; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name _; # ------------------------- # React frontend # ------------------------- root /usr/share/nginx/html; index index.html; location / { try_files $uri /index.html; } # ------------------------- # Django backend API # ------------------------- location /api { return 301 /api/; } location /api/ { proxy_pass http://backend:8000; 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; } # ------------------------- # Static & media files (Django) # ------------------------- location /static/ { alias /app/collectedstaticfiles/; } location /media/ { alias /app/media/; } # ------------------------- # Security headers # ------------------------- add_header X-Frame-Options "SAMEORIGIN"; add_header X-Content-Type-Options "nosniff"; add_header Referrer-Policy "strict-origin-when-cross-origin"; add_header Content-Security-Policy "default-src 'self' 'unsafe-inline' 'unsafe-eval' data: blob:;"; } }