Ouais. Autant dire que si des experts comme vous, les gars, n'arrivez pas à vos fins, je ne suis pas à la veille d'y arriver.
On en reparle dans un an
On en reparle dans un an

<IfModule mod_headers.c> Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS </IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
<IfModule mod_headers.c> Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS </IfModule>
# Force HTTPS (don't use this if you're still on http) # env=HTTPS didn't work... but while "expr=%{HTTPS} == 'on'" is well working
# see https://stackoverflow.com/questions/24144552/how-to-set-hsts-header-from-htaccess-only-on-https
#comment81632711_24145033
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" "expr=%{HTTPS} == 'on'"
# VirtualHost du domaine ***********.fr
## ## ## Port 80 ## ## ##
<VirtualHost *:80>
ServerName ***********.fr
ServerAlias www.***********.fr
DocumentRoot /var/www/***********.fr
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_rewrite.c>
RewriteEngine on
# Redirection de http vers https.
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</IfModule>
</VirtualHost>
## ## ## Port 443 ## ## ##
<VirtualHost *:443>
ServerName ***********.fr
ServerAlias www.***********.fr
ServerAdmin mail@***********.com
DocumentRoot /var/www/***********.fr
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# CSP - Politique de sécurité du contenu.
<IfModule mod_headers.c>
# Charger l'entête HSTS.
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
# Protéger des failles X-XSS X-Frame X-Content.
Header set X-XSS-Protection "1; mode=block"
Header always set X-Frame-Options "SAMEORIGIN"
Header set X-Content-Type-Options nosniff
# A mettre en place en fonction de vos besoins.
#Header set Access-Control-Allow-Origin: "..."
#Header set Content-Security-Policy: "..."
# Le navigateur n'enverra pas l'en-tête du référent lors de la navigation de HTTPS vers HTTP.
Header always set Referrer-Policy 'no-referrer-when-downgrade'
# Identique à CSP mais au lieu de contrôler la sécurité c'est un contrôle des fonctionnalités.
Header always set Feature-Policy "geolocation none;midi none;notifications none;push none;sync-xhr self;microphone none;camera none;magnetometer none;gyroscope none;speaker self;vibrate none;fullscreen self;payment none;"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
# Redirection de https non-www vers https www
RewriteCond %{SERVER_NAME} !^www\.(.*)$ [NC]
RewriteRule ^ https://www.%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</IfModule>
</VirtualHost>
Commentaire