Let's Encrypt et Apache
Alias /.well-known/acme-challenge/ /var/www/html/.well-known/acme-challenge/ <Directory "/var/www/html/.well-known/acme-challenge/"> Options None AllowOverride None ForceType text/plain RedirectMatch 404 "^(?!/\.well-known/acme-challenge/[\w-]{43}$)" </Directory>
Penser à recharger la configuration service apache2 reload
Créer un fichier de configuration /etc/letsencrypt/cli.ini contenant :
# This is an example of the kind of things you can do in a configuration file. # All flags used by the client can be configured here. Run Certbot with # "--help" to learn more about the available options. # Use a 4096 bit RSA key instead of 2048 rsa-key-size = 4096 # Uncomment and update to register with the specified e-mail address # email = foo@example.com email = foo@example.com # Uncomment and update to generate certificates for the specified # domains. # domains = example.com, www.example.com # Uncomment to use a text interface instead of ncurses # text = True # Uncomment to use the standalone authenticator on port 443 # authenticator = standalone # standalone-supported-challenges = tls-sni-01 # Uncomment to use the webroot authenticator. Replace webroot-path with the # path to the public_html / webroot folder being served by your web server. # authenticator = webroot # webroot-path = /usr/share/nginx/html authenticator = webroot webroot-path = /var/www/html
Créer les nouveaux certificats Let's Encrypt avec certbot certonly -d FQDN
Le webroot doit toujours être /var/www/html quelque soit le virtual host, puisque tous les VirtualHosts en disposent dans la configuration générale
Configurer le VirtualHost nouvellement créé avec :
<VirtualHost *:443> SSLEngine on SSLCertificateFile /etc/letsencrypt/live/FQDN/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/FQDN/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/FQDN/chain.pem Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload" [...] </VirtualHost>Penser à recharger la configuration service apache2 reload
Créer le renouvellement automatique avec /etc/cron.d/certbot :
22 7 * * * root /usr/bin/certbot renew --post-hook "service apache reload"Une fois que le service a bien été vérifé, ajouter l'option -q pour n'afficher que les erreurs.