server { listen 80; server_name localhost; root /usr/share/nginx/html; index index.html; # ============================================ # EN-TÊTES DE SÉCURITÉ # ============================================ # Protection contre le clickjacking add_header X-Frame-Options "DENY" always; # Prévention de la détection MIME incorrecte add_header X-Content-Type-Options "nosniff" always; # Protection XSS add_header X-XSS-Protection "1; mode=block" always; # Politique de référent add_header Referrer-Policy "same-origin" always; # Politique de sécurité de contenu (CSP) add_header Content-Security-Policy "default-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https: blob:; script-src 'self' 'unsafe-eval' 'unsafe-hashes'; connect-src 'self' ws: wss: https://api.ipify.org data: blob:; object-src 'none'; media-src 'self' blob:; frame-src 'self';" always; # HSTS - Force HTTPS (à activer uniquement en production avec HTTPS) add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; # Permissions Policy - camera et microphone autorisés pour la capture de fails add_header Permissions-Policy "camera=*, microphone=*, geolocation=(), payment=()" always; # Sécurité - masquer la version nginx server_tokens off; # ============================================ # CONFIGURATION ANGULAR SPA # ============================================ # Gérer les routes Angular (fallback vers index.html) location / { try_files $uri $uri/ /index.html; } # Cache pour les assets statiques location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { expires 1y; add_header Cache-Control "public, immutable"; } # Gestion spéciale pour les fichiers de service worker location /ngsw-worker.js { expires off; add_header Cache-Control "no-cache"; } # Gestion des erreurs error_page 404 /index.html; }