# nginx configuration for a React SPA (React Router support) server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # Gzip gzip on; gzip_vary on; gzip_min_length 1024; gzip_types text/plain text/css application/javascript application/json image/svg+xml image/x-icon font/woff2; # Long-lived cache for hashed assets (Vite outputs hash in filename) location ~* \.(?:js|css|woff2?|ttf|ico|png|jpg|jpeg|gif|svg|webp)$ { expires 1y; add_header Cache-Control "public, immutable"; access_log off; } # index.html — no cache; browser always re-validates location = /index.html { add_header Cache-Control "no-store"; } # SPA fallback — any unknown path serves index.html so React Router works location / { try_files $uri $uri/ /index.html; } # Hide nginx version in error responses server_tokens off; }