# ============================================================================ # nginx config for the UI container. # # Two jobs: # 1. Serve the Vite-built static assets under / # 2. Proxy /api/* to the API container (service name "api" on the compose # network). This mirrors the Vite dev-server proxy in ui/vite.config.ts # so the frontend's fetch("/extract") calls work identically in dev and # in the compose stack. # ============================================================================ server { listen 5173; server_name _; # Compressed responses for text-y assets (JS, CSS, HTML, JSON). gzip on; gzip_types text/plain text/css application/json application/javascript application/xml+rss text/javascript image/svg+xml; gzip_min_length 1024; # Static assets — long-cache with immutable hint. Vite fingerprints # filenames, so a new build cache-busts automatically. location /assets/ { root /usr/share/nginx/html; expires 1y; add_header Cache-Control "public, immutable"; } # API proxy — strip the /api prefix so the FastAPI routes stay clean. # `service_healthy` in compose guarantees this backend is up before we # accept traffic here. 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; # Extraction can take 20-60s for large PDFs, so bump the read timeout # above the nginx default (60s). proxy_connect_timeout 10s; proxy_read_timeout 120s; # Big uploads: 10-K filings can be 5+ MB. client_max_body_size 20m; } # SPA fallback — any non-file route falls back to index.html so React # Router (or hash routing) can take over. location / { root /usr/share/nginx/html; index index.html; try_files $uri $uri/ /index.html; } }