events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; sendfile on; # ── Gzip compression ────────────────────────────────────────────────────── gzip on; gzip_types text/plain text/css application/javascript application/json; gzip_min_length 1000; server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # ── Static files ────────────────────────────────────────────────────── location / { try_files $uri $uri.html $uri/ =404; } # Cache static assets aggressively and suppress access log noise location ~* \.(css|js|svg|ico|png|jpg|webp|woff2?)$ { expires 7d; add_header Cache-Control "public, immutable"; access_log off; } # ── API reverse proxy ───────────────────────────────────────────────── # All /api/* requests are forwarded to the FastAPI container. # The container is reachable by its service name on the Docker network. 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; # Don't cache API responses add_header Cache-Control "no-store"; } # ── Custom error pages ──────────────────────────────────────────────── error_page 404 /404.html; error_page 502 503 504 /50x.html; location = /404.html { internal; } location = /50x.html { internal; } } }