Install Certbot on EC2 instances running Amazon Linux 2023, request and install Let’s Encrypt SSL/TLS certificate

Technology

Install Certbot on EC2 instances running AL2023 (Amazon Linux 2023), use it to request and install Let’s Encrypt SSL/TLS certificate on either Apache or Nginx web server, with automated renewal

Certbot is a tool to obtain SSL/TLS certificates from Let’s Encrypt and (optionally) auto-enable HTTPS on your server.

Requirements

Ensure that you have

Install Certbot

sudo dnf install -y certbot python3-certbot-dns-route53 python3-certbot-apache python3-certbot-nginx
sudo systemctl daemon-reload
sudo systemctl enable --now certbot-renew.timer

Install and Configure Apache

sudo dnf install -y httpd mod_ssl
sudo tee /etc/httpd/conf.d/www.conf > /dev/null << EOF
<VirtualHost *:80>
  DocumentRoot /var/www/html
</VirtualHost>
EOF

sudo systemctl enable --now httpd

Certbot uses Apache Virtual Hosts to identify web sites and install certs.

Request and install HTTPS cert

sudo certbot --apache

Enter valid email address, agree to Let’s Encrypt Terms of Service, optionally subscribe to EFF mailing list, input your FQDN, to have Certbot request and install HTTPS certificate on your Apache server.

Verify certificate

To display information about certificates you have from Certbot

sudo certbot certificates

Automated Renewal

Certbot use certbot-renew systemd daily for automated renewal of any certificate 30 days before their expiry dates. To verify certbot-renew operation

journalctl -u certbot-renew -f

More information

Refer to Certbot User Guide

Credit: https://repost.aws/articles/AR_doGU0cxQymwf5A1Gl97yA/use-certbot-to-enable-https-with-apache-or-nginx-on-ec2-instances-running-amazon-linux-2023-al2023

Leave a Reply

Your email address will not be published. Required fields are marked *