Hoe beveilig je Apache met Let’s Encrypt op CentOS 8
In deze blog zetten we de nodige stappen uiteen hoe je Apache beveiligt met Let’s Encrypt op CentOS 8. Voordat je doorgaat met deze tutorial, controleer of je ingelogd bent als gebruiker met sudo-rechten. Alle commando’s dienen uitgevoerd te worden als een non-root user.
Let’s Encrypt is een certificeringsinstantie dat gratis SSL-certificaten levert voor websites. Het is sinds 2016 actief is en wordt ondersteund door bedrijven en internetorganisaties over de hele wereld, zoals Mozilla, Cisco, Chrome, enz.
CentOS 8 Basis
De basis voor de onderstaande cases is een minimal install van CentOS 8.2. Voer onderstaande commando’s in voor EPEL repository en update.
sudo dnf update -y
Stap 1. Installeer de SSL modules
sudo systemctl restart https
Voordat je Let’s Encrypt SSL installeert, moet het domein toegankelijk zijn en de virtuele Apache-host gebruiken. Bekijk anders eerst de tutorial over ‘hoe je Apache op CentOS 8 installeert’.
Stap 2. Installeer Certbot
Certbot is een gratis command-line tool die het proces voor het verkrijgen en vernieuwen van Let’s Encrypt SSL-certificaten en het automatisch inschakelen van HTTPS op uw server vereenvoudigt:
Stap 3. Configureer een certificaat
Voer vervolgens het onderstaande commando uit om een certificaat te verkrijgen. Certbot laat je Apache-configuratie automatisch bewerken om het te bedienen, waarbij je HTTPS-toegang in een enkele stap activeert:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices)
(Enter ‘c’ to cancel): admin@axxius.nl
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
(A)gree/(C)ancel: A
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let’s Encrypt project and the non-profit organization that
develops Certbot? We’d like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
(Y)es/(N)o: N
No names were found in your configuration files. Please enter in your domain
name(s) (comma and/or space separated) (Enter ‘c’ to cancel): example.com
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
Cleaning up challenges
!! ERROR
Unable to find a virtual host listening on port 80 which is currently needed for Certbot to prove to the CA that you control your domain. Please add a virtual host for port 80.
IMPORTANT NOTES:
– Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
Stap 4. Stel automatische verlenging in
Het SSL-certificaat is slechts 90 dagen geldig. Voer het onderstaande commando uit voor een automatische verlenging:
Stap 5. Controleer de status van je certificaat
Je kunt ervoor zorgen dat Certbot het SSL-certificaat correct heeft aangemaakt door het gebruik te maken van de SSL-servertest van het cloudbeveiligingsbedrijf Qualys.
IT-traineeship
Gefeliciteerd, je hebt Apache beveiligd op CentOS 8 met Let’s Encrypt. Mocht je jezelf nog verder willen ontwikkelen met bijvoorbeeld container technologie zoals Docker en Kubernetes en willen weten hoe je dit kan implementeren voor een organisatie in de Cloud? Dan is het Axxius IT-traineeship precies wat je zoekt. Neem contact met ons op zodat wij een eerste gesprek kunnen inplannen en de mogelijkheden met jou kunnen bespreken.