server { listen 80; listen [::]:80; server_name _; root /usr/share/nginx/html; index index.html; server_tokens off; gzip on; gzip_vary on; gzip_min_length 1024; gzip_proxied any; gzip_types text/plain text/css text/javascript application/javascript application/json application/xml image/svg+xml font/woff font/woff2; # NOTE: add_header does not inherit into a location that declares its own, # so the security headers are repeated in each block rather than set once # at server level (where they would be silently dropped). # Content-hashed build output. Safe to cache forever: a new deploy emits new # filenames, so a stale cache can never serve the wrong bundle. # `expires` is deliberately not used here -- it emits its own Cache-Control # and the two would conflict. location /assets/ { add_header Cache-Control "public, max-age=31536000, immutable" always; add_header X-Content-Type-Options "nosniff" always; access_log off; try_files $uri =404; } # The app shell. Must never be cached, or browsers keep booting the old # bundle after a deploy and users report "the update didn't work". location = /index.html { add_header Cache-Control "no-cache, no-store, must-revalidate" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; } # SPA fallback. index.html carries the theme bootstrap script, so an # unknown route must still resolve to a normal 200 document. location / { add_header Cache-Control "no-cache" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; try_files $uri $uri/ /index.html; } }