server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # Docusaurus emits clean URLs as directories with an index.html, plus # standalone .html files (e.g. the legacy redirect pages). Try the exact # file, then the directory index, then a .html sibling, before 404. location / { try_files $uri $uri/ $uri.html =404; } # Long-cache fingerprinted static assets. location /assets/ { try_files $uri =404; expires 7d; add_header Cache-Control "public"; } # Docusaurus content-hashed bundles can be cached aggressively. location ~* \.(?:js|css|woff2?|svg|png|jpg|jpeg|gif|ico)$ { expires 30d; add_header Cache-Control "public, immutable"; } error_page 404 /404.html; # Basic security headers. 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; }