server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # ── API proxy → Fastify ────────────────────────────────────────────────── location /api/ { proxy_pass http://server:3001; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } # ── SEO proxy → Fastify (dynamique depuis DB) ───────────────────────────── location = /robots.txt { proxy_pass http://server:3001; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } location = /sitemap.xml { proxy_pass http://server:3001; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } # ── Admin proxy → Fastify (AdminJS) ────────────────────────────────────── location /admin { proxy_pass http://server:3001; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } # ── Cache : Astro hashed files → immutable ─────────────────────────────── location /_astro/ { add_header Cache-Control "public, max-age=31536000, immutable"; } # ── Cache : CSS/JS sans hash → revalidation ───────────────────────────── location ~* \.(css|js)$ { add_header Cache-Control "no-cache"; } # ── Cache : assets (images, fonts) → 7 jours ──────────────────────────── location ~* \.(jpg|jpeg|png|gif|webp|svg|woff2|woff|ttf|ico)$ { add_header Cache-Control "public, max-age=604800"; } # ── HTML : jamais caché ────────────────────────────────────────────────── location ~* \.html$ { add_header Cache-Control "no-store"; } # ── SPA fallback pour les routes Astro ─────────────────────────────────── location / { try_files $uri $uri/ $uri.html /index.html; } }