server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # Gzip gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml image/svg+xml; # Résolveur DNS Docker — résolution à la requête, pas au démarrage resolver 127.0.0.11 valid=10s ipv6=off; # Proxy API vers backend location /api/ { set $backend http://backend:8080; proxy_pass $backend; 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_read_timeout 3600s; proxy_connect_timeout 10s; proxy_send_timeout 3600s; } # Service Worker — ne pas mettre en cache location = /sw.js { add_header Cache-Control "no-cache, no-store, must-revalidate"; add_header Pragma "no-cache"; expires 0; } # Assets statiques avec cache long location /assets/ { add_header Cache-Control "public, max-age=31536000, immutable"; } # SPA — renvoyer index.html pour toutes les routes React location / { try_files $uri $uri/ /index.html; add_header Cache-Control "no-cache"; } }