wilddragon-site/nginx.conf
Zac Gaetano d4d46b085e fix(deploy): content-hash cache-busting + block source/config leaks + real 404s
- build.sh stamps ?v=<md5> on JS/CSS refs; Cloudflare was serving 4h-stale bundles
- nginx: 404 for .mjs/.md/.yml/.sh/.conf/Dockerfile/dotfiles (build-pages.mjs, README, compose were public)
- nginx: unknown paths 404 instead of soft-404 SPA fallback (Search Console soft-404s)
- track live nginx.conf in repo
2026-10-01 20:43:16 -04:00

59 lines
1.8 KiB
Nginx Configuration File

server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
charset utf-8;
gzip on;
gzip_types text/plain text/css text/javascript application/javascript application/json application/xml image/svg+xml;
gzip_min_length 1024;
gzip_comp_level 6;
gzip_vary on;
# Security headers
add_header X-Frame-Options SAMEORIGIN always;
add_header X-Content-Type-Options nosniff always;
add_header Referrer-Policy strict-origin-when-cross-origin always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
# Vendored libs — versioned, cache hard
location /vendor/ {
expires 365d;
add_header Cache-Control "public, immutable";
}
# Images/fonts — long cache
location ~* \.(png|jpg|jpeg|gif|webp|avif|svg|ico|woff2?|ttf)$ {
expires 30d;
add_header Cache-Control "public, no-transform";
}
# App JS/CSS — short cache so edits show fast
location ~* \.(css|js)$ {
expires 10m;
add_header Cache-Control "public, must-revalidate";
}
# Never serve build sources, docs, or deploy config
location ~* (\.(jsx|mjs|py|sh|md|ya?ml|conf|tgz)|/Dockerfile)$ { return 404; }
location ~ /\. { return 404; }
location /scripts/ { return 404; }
location = /robots.txt { default_type text/plain; }
location = /llms.txt { default_type text/plain; }
location = /sitemap.xml { default_type application/xml; }
# HTML — no stale cache
location = /index.html {
add_header Cache-Control "no-cache, must-revalidate";
}
# Real 404s for unknown paths (SPA routes via location.hash, so / covers them).
# ponytail: plain nginx 404 page; add a branded 404.html if traffic warrants it
location / {
try_files $uri $uri/ =404;
}
}