# /etc/nginx/sites-available/choisismoi.com server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name choisismoi.com www.choisismoi.com *.choisismoi.com; # Certificats Sectigo ssl_certificate /etc/ssl/choisismoi.com/fullchain.pem; ssl_certificate_key /etc/ssl/choisismoi.com/privkey.key; ### Paramètres SSL renforcés (OCSP Stapling + Modern TLS) ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384'; ssl_ecdh_curve secp384r1; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 1d; ssl_session_tickets off; ssl_stapling on; ssl_stapling_verify on; resolver 1.1.1.1 8.8.8.8 valid=300s; resolver_timeout 5s; ### En-têtes de sécurité complets add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always; add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' https:; img-src 'self' data: https:; style-src 'self' 'unsafe-inline' https:; font-src 'self' https:;" always; add_header Permissions-Policy "geolocation=(), midi=(), camera=(), microphone=()" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; ### Configuration du root root /var/www/choisismoi.com/html; index index.php index.html; ### Journalisation optimisée access_log /var/log/nginx/choisismoi.com.access.log combined buffer=32k flush=5m; error_log /var/log/nginx/choisismoi.com.error.log warn; ### Règles principales location / { try_files $uri $uri/ /index.php?$args; limit_req zone=ratelimit burst=20 nodelay; } ### Gestion PHP sécurisée location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php8.3-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; # Protection renforcée fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_intercept_errors on; fastcgi_read_timeout 300; fastcgi_buffer_size 128k; fastcgi_buffers 256 16k; } ### Protection avancée location ~* ^/(\.|conf|bin|inc|vendor|composer\.|README|LICENSE) { deny all; return 404; } location ~* \.(log|conf|bak|swp|sql|tpl|twig|yml)$ { deny all; return 403; } ### Optimisation des assets location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|webp|avif|woff2)$ { expires 1y; add_header Cache-Control "public, immutable, no-transform"; access_log off; try_files $uri =404; } ### Spécifiques location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } ### Zone de rate limiting limit_req_zone $binary_remote_addr zone=ratelimit:10m rate=10r/s; } ### Redirection HTTP → HTTPS avec HSTS preload server { listen 80; listen [::]:80; server_name choisismoi.com www.choisismoi.com *.choisismoi.com; add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always; return 301 https://$host$request_uri; }