server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; gzip on; gzip_vary on; gzip_min_length 1024; gzip_types text/plain text/css application/javascript application/json image/svg+xml; location = /healthz { access_log off; default_type text/plain; return 200 "ok"; } # API traffic → FastAPI backend (compose service `api` on :8000) location /api/ { proxy_pass http://api:8000; proxy_http_version 1.1; 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_read_timeout 60s; } # Hashed build assets: cache aggressively location /assets/ { expires 30d; add_header Cache-Control "public, max-age=2592000, immutable"; try_files $uri =404; } # SPA fallback; never cache the HTML shell location / { try_files $uri $uri/ /index.html; add_header Cache-Control "no-store"; } }