Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
informatique:serveur:web-linux-apache:https_www_apache2 [2023/02/09 16:12] – supprimée - modification externe (Unknown date) | informatique:serveur:web-linux-apache:https_www_apache2 [2023/02/09 16:14] (Version actuelle) – ↷ Liens modifiés en raison d'un déplacement. Cédric ABONNEL | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== Configurer un site en https ====== | ||
+ | {{ informatique: | ||
+ | Votre certificat a été généré grâce à **Certbot**. Il faut désormais configurer **Apache** pour utiliser de manière systématique ce certificat. | ||
+ | |||
+ | Voici mes prises de notes pour passer un site Internet **http** en **https**. Le configuration est destinée pour un site Internet dont le sous-domaine est **www**. Il est très facilement adaptable pour un site avec un sous-domaine différent. | ||
+ | |||
+ | < | ||
+ | Configurer Apache 2 | ||
+ | http:// | ||
+ | </ | ||
+ | |||
+ | Je viens de demander un certificat SSL pour le site Internet '' | ||
+ | * les demandes en https utilisent le certificat SSL | ||
+ | * toutes les visites en http soit redirigées en https | ||
+ | |||
+ | ====== Configurer ====== | ||
+ | |||
+ | |||
+ | Je complète le fichier de configuration ''/ | ||
+ | |||
+ | < | ||
+ | RewriteEngine On | ||
+ | RewriteCond %{HTTPS} off | ||
+ | RewriteCond %{REQUEST_URI} !\.well-known/ | ||
+ | RewriteRule ^(.*)$ https:// | ||
+ | </ | ||
+ | |||
+ | Puis, j' | ||
+ | J' | ||
+ | * [[linux: | ||
+ | * [[linux: | ||
+ | * Ajout des options SSL | ||
+ | * Ajout de la gestion des certificats | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | |||
+ | ServerName perdu.com | ||
+ | ServerAlias www.perdu.com | ||
+ | | ||
+ | Protocols h2 http/1.1 | ||
+ | |||
+ | DocumentRoot / | ||
+ | |||
+ | < | ||
+ | Options -Indexes +MultiViews | ||
+ | AllowOverride all | ||
+ | Order allow,deny | ||
+ | allow from all | ||
+ | </ | ||
+ | |||
+ | |||
+ | < | ||
+ | Require all granted | ||
+ | </ | ||
+ | |||
+ | LogLevel warn | ||
+ | ErrorLog ${APACHE_LOG_DIR}/ | ||
+ | CustomLog ${APACHE_LOG_DIR}/ | ||
+ | |||
+ | SSLCertificateFile / | ||
+ | SSLCertificateKeyFile / | ||
+ | SSLCertificateChainFile / | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | Les options SSL sont à créer une seule fois sur le serveur. Ces options sont communes à tous les sites Internet que je configure. | ||
+ | Les options dans ''/ | ||
+ | < | ||
+ | |||
+ | # Intermediate configuration | ||
+ | SSLProtocol -ALL +TLSv1.2 | ||
+ | SSLCipherSuite ECDHE-RSA-AES256-GCM-SHA384: | ||
+ | SSLHonorCipherOrder | ||
+ | # | ||
+ | |||
+ | SSLOptions +StrictRequire | ||
+ | SSLCompression | ||
+ | |||
+ | # HSTS (mod_headers is required) (15768000 seconds = 6 months) | ||
+ | Header always set Strict-Transport-Security " | ||
+ | |||
+ | # Always ensure Cookies have " | ||
+ | Header edit Set-Cookie (? | ||
+ | |||
+ | </ | ||
+ | |||
+ | Il convient de désactiver ces options dans le fichier ''/ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | |||
+ | Ce qui donne une configuration globale suivante : | ||
+ | |||
+ | < | ||
+ | < | ||
+ | |||
+ | ServerName perdu.com | ||
+ | ServerAlias www.perdu.com | ||
+ | | ||
+ | Protocols h2 http/1.1 | ||
+ | |||
+ | DocumentRoot / | ||
+ | |||
+ | < | ||
+ | Options -Indexes +MultiViews | ||
+ | AllowOverride all | ||
+ | Order allow,deny | ||
+ | allow from all | ||
+ | </ | ||
+ | |||
+ | |||
+ | < | ||
+ | Require all granted | ||
+ | </ | ||
+ | |||
+ | LogLevel warn | ||
+ | ErrorLog ${APACHE_LOG_DIR}/ | ||
+ | CustomLog ${APACHE_LOG_DIR}/ | ||
+ | |||
+ | # Redirection des URL vers https | ||
+ | RewriteEngine On | ||
+ | RewriteCond %{HTTPS} off | ||
+ | RewriteCond %{REQUEST_URI} !\.well-known/ | ||
+ | RewriteRule ^(.*)$ https:// | ||
+ | |||
+ | </ | ||
+ | |||
+ | < | ||
+ | < | ||
+ | |||
+ | ServerName perdu.com | ||
+ | ServerAlias www.perdu.com | ||
+ | | ||
+ | Protocols h2 http/1.1 | ||
+ | |||
+ | DocumentRoot / | ||
+ | |||
+ | < | ||
+ | Options -Indexes | ||
+ | AllowOverride all | ||
+ | Order allow,deny | ||
+ | allow from all | ||
+ | </ | ||
+ | |||
+ | |||
+ | < | ||
+ | Require all granted | ||
+ | </ | ||
+ | |||
+ | LogLevel warn | ||
+ | ErrorLog ${APACHE_LOG_DIR}/ | ||
+ | CustomLog ${APACHE_LOG_DIR}/ | ||
+ | | ||
+ | SSLCertificateFile / | ||
+ | SSLCertificateKeyFile / | ||
+ | SSLCertificateChainFile / | ||
+ | |||
+ | |||
+ | </ | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ====== Recharger ====== | ||
+ | |||
+ | Après ces modifications, | ||
+ | < | ||
+ | sudo service apache2 reload | ||
+ | </ | ||
+ | |||
+ | ====== Zone DNS ====== | ||
+ | |||
+ | Il est possible d' | ||
+ | Il s'agit du //DNS Certification Authority Authorization (CAA)// à activer grâce à un enregistrement **CAA** de la zone DNS : | ||
+ | www IN CAA 128 issue " | ||
+ | perdu.com. | ||
+ | |||
+ | |||
+ | |||
+ | ====== Tester ====== | ||
+ | |||
+ | |||
+ | Vous pouvez tester votre site grâce à l' | ||
+ | |||