server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; gzip on; gzip_types text/plain text/css text/javascript application/javascript application/json application/xml image/svg+xml; gzip_min_length 256; gzip_vary on; # Reverse-proxy API calls to the internal api service on the compose network. location /api/ { proxy_pass http://api:3001/api/; 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_buffering off; client_max_body_size 10m; } # Hashed assets — cache aggressively, never revalidate. location ~* \.(?:js|css|woff2?|svg|png|jpg|jpeg|gif|ico|webp)$ { expires 1y; add_header Cache-Control "public, immutable"; try_files $uri =404; } # SPA fallback — always serve fresh index.html. location / { try_files $uri $uri/ /index.html; add_header Cache-Control "no-cache"; } }