server { listen 8080; server_name localhost; root /usr/share/nginx/html; index index.html; server_tokens off; gzip on; gzip_vary on; gzip_comp_level 6; gzip_min_length 256; gzip_types text/plain text/css text/xml application/json application/javascript application/xml image/svg+xml; # NOTE: add_header does not inherit into a location block that sets # its own add_header, so these three lines are repeated in every # location below rather than declared once here. location = /health { access_log off; return 200 "ok\n"; add_header Content-Type text/plain always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; } # Hashed build assets (Vite output) can be cached forever. location /assets/ { try_files $uri =404; add_header Cache-Control "public, max-age=31536000, immutable" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; } # index.html must always be revalidated so SPA routing/asset # references stay in sync with the latest deployed build. location = /index.html { add_header Cache-Control "no-cache" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; } location / { try_files $uri $uri/ /index.html; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; } location ~ /\. { deny all; } }