Pour protéger efficacement votre site en production (au-delà des balises Meta HTML), il est fortement conseillé de déployer ces en-têtes HTTP de sécurité sur votre serveur web.
Apache (Fichier .htaccess)
# Protéger contre le MIME-Sniffing
Header set X-Content-Type-Options "nosniff"
# Protection contre le Clickjacking
Header set X-Frame-Options "DENY"
# Filtrage XSS
Header set X-XSS-Protection "1; mode=block"
# Referrer Policy strict
Header set Referrer-Policy "strict-origin-when-cross-origin"
# Force HTTPS (HSTS) - Si HTTPS activé
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"
# Politique de Sécurité du Contenu (CSP Strict)
Header set Content-Security-Policy "default-src 'self' https:; script-src 'self' 'unsafe-inline' https://cdn.tailwindcss.com https://unpkg.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com;"
Nginx (Fichier de configuration nginx.conf)
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
💡 Conseil : Ces directives bloquent le détournement de fenêtres (Clickjacking), l'injection de scripts malveillants et garantissent le chiffrement des connexions.