server { listen 80; server_name _; include /etc/nginx/mime.types; types { application/javascript mjs; application/wasm wasm; } # Match MAX_UPLOAD_MB — raise in both this and the outer reverse proxy client_max_body_size 200m; # Security headers add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "no-referrer" always; add_header Content-Security-Policy "default-src 'self'; script-src 'self' blob: 'wasm-unsafe-eval'; worker-src 'self' blob:; style-src 'self' 'unsafe-inline'; img-src 'self' blob: data:; font-src 'self' data:; connect-src 'self';" always; # SPA: serve index.html for all non-file routes (history API fallback) root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; } # Proxy /api/ to the backend container 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; # Pass through auth cookies and CSRF header proxy_pass_header Set-Cookie; proxy_set_header Cookie $http_cookie; proxy_set_header X-Requested-With $http_x_requested_with; # Timeouts for large uploads/exports proxy_connect_timeout 60s; proxy_send_timeout 120s; proxy_read_timeout 120s; # Upload size (must match client_max_body_size) client_max_body_size 200m; } # Cache static assets location ~* \.(js|mjs|wasm|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; try_files $uri =404; } # Disable access to hidden files location ~ /\. { deny all; access_log off; log_not_found off; } }