Let's Encrypt issues free TLS certificates trusted by every browser, and certbot obtains and renews them automatically. It takes five minutes to set up, and then one day the certificate suddenly expires, renewal fails on rate limits, or the site serves an incomplete chain. Here is how it all works and how to make it run for years without attention.

How Let's Encrypt checks your domain

Before issuing a certificate you have to prove you control the domain. There are two main ways:

Validation happens from several locations around the world at once. If the site is closed to foreign addresses (geo-blocking in the firewall or at the hosting level), HTTP-01 fails: use DNS-01 or open at least the /.well-known/acme-challenge/ path to everyone.

Installation and the first certificate

sudo apt install certbot python3-certbot-nginx     # Debian, Ubuntu
sudo dnf install certbot python3-certbot-nginx     # AlmaLinux, Rocky (from EPEL)

Then one of three modes:

# nginx: certbot finds server_name and adds the certificate itself
sudo certbot --nginx -d example.com -d www.example.com

# webroot: the web server is left alone, the file goes into the site folder
sudo certbot certonly --webroot -w /var/www/example -d example.com

# standalone: certbot's own temporary web server, port 80 must be free
sudo certbot certonly --standalone -d example.com

The --nginx mode is convenient, but it edits your configuration itself. If you keep the configuration in git or build it with a generator, certonly --webroot with your own nginx lines is more reliable.

Ready-made commands for nginx, your own folder, DNS validation via Cloudflare or by hand, with installation for different systems and a CAA record, are built by Let’s Encrypt certificate.

Which files to use

The certificates live in /etc/letsencrypt/live/example.com/:

These are links to the latest files in archive/, so the paths don't change after renewal; you only need to reload the web server. What is inside a certificate, its dates and chain are shown by Certificates and CSR.

Automatic renewal

A certificate is valid for 90 days, and Let's Encrypt is gradually shortening that period, so renewal has to run by itself. The certbot package installs a systemd timer or cron job that checks certificates twice a day and renews those with less than 30 days left.

systemctl list-timers | grep certbot     # the timer exists and is scheduled
sudo certbot renew --dry-run             # a test renewal without issuing

The web server sees a renewed certificate only after reloading its configuration. Add a hook that runs after every successful renewal:

sudo tee /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh <<'EOF'
#!/bin/sh
systemctl reload nginx
EOF
sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh
No more expiry emails. Since 2025 Let's Encrypt no longer sends reminders that a certificate is about to expire. If renewal breaks, you will hear about it from visitors, so watch the expiry date yourself: with monitoring or a simple cron check.

Wildcard certificates

*.example.com requires DNS validation. You can get the certificate by hand (--manual --preferred-challenges dns), but you can't renew it automatically: you would have to change the TXT record by hand every time. Automatic renewal needs a plugin for your DNS provider, such as python3-certbot-dns-cloudflare, and an API token allowed to change records only in the zone you need.

Rate limits and common errors

Next: setting up HTTPS

Getting a certificate is half the job: you also need to turn off old TLS versions and enable redirects and HSTS. That is covered in the article on HTTPS with nginx, and ready-made configurations come from the nginx config generator and TLS configuration. For the Russian Ministry of Digital Development certificate, see the article about it.