ACLClouds
ACLClouds

How do I install a Let's Encrypt certificate (free HTTPS) on a VPS?

Get a free SSL certificate with Certbot for nginx or Apache, in standalone mode or as a DNS wildcard with Cloudflare, check automatic renewal and fix

Let's Encrypt is a free, automated certificate authority: it issues TLS certificates trusted by every browser, valid for 90 days. Certbot, the client maintained by the EFF, requests the certificate, configures nginx or Apache and renews it on its own. This guide covers Debian 12 / 13 and Ubuntu 22.04 / 24.04: nginx, Apache, standalone mode without a web server, a wildcard certificate through DNS validation with Cloudflare, renewal with a systemd timer, the Caddy alternative and the most frequent errors.

Step-by-step procedure

  1. Point the domain to the VPS

    Create an A record pointing to the VPS IPv4, plus an AAAA record if the VPS has an IPv6, then check with dig +short example.com A that the answer is that address. Let's Encrypt checks the domain from several locations on the Internet: until DNS answers everywhere, the request fails.

  2. Open ports 80 and 443

    HTTP validation always goes through port 80, even if the site is then served only over HTTPS. Allow TCP 80 and 443 in UFW and in the "Firewall" tab of the ACLClouds panel if it is enabled.

  3. Install Certbot and the web server plugin

    Install certbot with python3-certbot-nginx or python3-certbot-apache. The package also enables the certbot.timer timer, which handles renewal.

  4. Request the certificate

    certbot --nginx -d example.com -d www.example.com validates both names, installs the certificate in the nginx configuration and offers to redirect HTTP to HTTPS. For Apache, replace --nginx with --apache. On the first request, Certbot asks for an email address and for you to accept the Let's Encrypt terms.

  5. Test renewal

    Run certbot renew --dry-run: Certbot simulates a full renewal against the Let's Encrypt staging environment, without touching the existing certificates. systemctl list-timers certbot.timer shows the next run of the timer.

  6. Check from outside

    Open https://example.com in a browser, or run curl -I https://example.com from another machine. certbot certificates lists the certificates, the names they cover and their expiry date.

Check DNS and open the ports

dig +short example.com A
dig +short www.example.com A
ufw allow 80/tcp
ufw allow 443/tcp
ufw status

Certbot with nginx

apt update
apt install -y certbot python3-certbot-nginx
certbot --nginx -d example.com -d www.example.com
nginx -t && systemctl reload nginx

Certbot with Apache

apt update
apt install -y certbot python3-certbot-apache
certbot --apache -d example.com -d www.example.com
apachectl configtest && systemctl reload apache2

Standalone mode and webroot mode

# Aucun serveur web sur le port 80 : Certbot démarre le sien
certbot certonly --standalone -d api.example.com

# Le serveur web reste en marche et sert le dossier du site
certbot certonly --webroot -w /var/www/html -d example.com -d www.example.com

ls /etc/letsencrypt/live/example.com/

/root/.secrets/cloudflare.ini

dns_cloudflare_api_token = CLOUDFLARE_API_TOKEN

Wildcard certificate with the Cloudflare plugin

apt install -y python3-certbot-dns-cloudflare
mkdir -p /root/.secrets && chmod 700 /root/.secrets
nano /root/.secrets/cloudflare.ini
chmod 600 /root/.secrets/cloudflare.ini
certbot certonly --dns-cloudflare --dns-cloudflare-credentials /root/.secrets/cloudflare.ini --dns-cloudflare-propagation-seconds 30 -d example.com -d '*.example.com'

Renewal: timer, test and hook

systemctl list-timers certbot.timer
certbot renew --dry-run
certbot certificates
cat > /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh <<'EOF'
#!/bin/sh
systemctl reload nginx
EOF
chmod 755 /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh

Install Caddy from its official repository

apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg /etc/apt/sources.list.d/caddy-stable.list
apt update
apt install -y caddy

/etc/caddy/Caddyfile

example.com, www.example.com {
    reverse_proxy localhost:8080
}

Before you start

You need a domain name whose DNS zone you manage, a Linux VPS with root access and a site or application that already responds over HTTP. The commands are run as root; with another account, put sudo in front of each one. Replace example.com with your domain.

  • Without a domain of your own, a free subdomain in aclclouds.online works too: create the A record pointing to the VPS IPv4, then request the certificate for that name.
  • Certbot is also available as a snap, the method the EFF recommends to get the latest version: snap install --classic certbot. Keep a single installation: remove the apt package before switching to the snap.
  • One certificate covers every name passed with -d: the bare domain and www do not need two certificates.

Choose the validation method

Let's Encrypt checks that you control the domain before signing the certificate. Certbot can answer this check in several ways, depending on what already runs on the VPS.

  • --nginx or --apache: the plugin edits the site configuration, gets the certificate and installs it. This is the most common case.
  • --webroot: Certbot places a file in the site folder, served by your web server, which keeps running. You then add the certificate to the configuration yourself.
  • --standalone: Certbot starts its own server on port 80. Handy for an API, a mail server or a service without a web server, as long as port 80 is free at the time of the request and of every renewal.
  • DNS validation (DNS-01): Certbot creates a _acme-challenge TXT record. It is the only method that accepts wildcard certificates, and it works even if port 80 is closed.

Wildcard certificate with Cloudflare

A *.example.com wildcard certificate covers every first-level subdomain, but not example.com itself: request both names. It must go through DNS validation. If the zone is on Cloudflare, the certbot-dns-cloudflare plugin creates and removes the TXT record by itself, which also makes renewal automatic.

In the Cloudflare dashboard, create an API token with the Zone > DNS > Edit permission, restricted to the zone in question, and paste it into cloudflare.ini. This file gives control over your DNS: keep it in mode 600, outside any Git repository. If validation fails because the TXT record is not visible yet, increase --dns-cloudflare-propagation-seconds (10 seconds by default).

  • Certbot has other DNS plugins, for example python3-certbot-dns-ovh for a zone at OVHcloud or python3-certbot-dns-route53 for AWS.
  • The --manual --preferred-challenges dns mode has you create the TXT record by hand: it helps as a one-off, but the certificate does not renew on its own.

How automatic renewal works

The Debian and Ubuntu package installs certbot.timer, a systemd timer that runs certbot renew twice a day at a random time. Certbot only renews certificates that are close to expiry: thirty days before expiry with the versions shipped by Debian 12 and Ubuntu 24.04, or when one third of the validity period remains from Certbot 4.0 onward. The snap installs its own timer, visible in systemctl list-timers.

After a renewal, the web server must reload the new certificate. The --nginx and --apache plugins take care of this. In other cases (webroot, standalone, Postfix, a container), place a script in /etc/letsencrypt/renewal-hooks/deploy/: it only runs when a certificate has actually changed.

  • In standalone mode, if a web server occupies port 80, add --pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx": Certbot stops it for a few seconds at each renewal.
  • Let's Encrypt has not sent expiry reminder emails since June 2025: monitor the date with certbot certificates or a tool such as Uptime Kuma.
  • The validity period is getting shorter: 64 days in February 2027, then 45 days in February 2028. Rely on the timer, not on a manual renewal every 60 days.

The Caddy alternative

Caddy is a web server that obtains and renews its certificates on its own, without Certbot: you just write the domain name in the Caddyfile. It uses Let's Encrypt, with ZeroSSL as a fallback, and redirects HTTP to HTTPS by default. It is the simplest choice to put a Node.js or Python application, or a container, behind HTTPS with reverse_proxy.

Caddy and nginx cannot both listen on ports 80 and 443: pick one or the other. The requirements stay the same (DNS pointing to the VPS, ports 80 and 443 open), and a wildcard needs a DNS module added to Caddy. After a change, systemctl reload caddy applies the Caddyfile.

Common errors and fixes

Certbot shows the cause of the failure in its message and in /var/log/letsencrypt/letsencrypt.log. Here are the most frequent ones.

  • Timeout during connect (likely firewall problem): Let's Encrypt cannot reach port 80. Open 80/tcp in UFW and in the panel firewall, then check that a server is listening with ss -ltnp | grep :80.
  • DNS problem: NXDOMAIN looking up A: the name does not exist in DNS yet, or it was just created. Wait for propagation and check with dig +short example.com A @1.1.1.1.
  • Validation reaches another server: a forgotten AAAA record pointing to an old machine makes the request fail, because Let's Encrypt tries IPv6 first. Fix or delete that AAAA record.
  • too many certificates already issued: the limit is 50 certificates per registered domain per week, or 5 identical certificates per week. Run your tests with --dry-run or --test-cert, which use the staging environment.
  • Could not bind TCP port 80 in standalone mode: nginx or Apache already occupies the port. Use --nginx or --webroot, or stop the web server during the request.
  • CAA record for example.com prevents issuance: a CAA record in the zone only authorizes another authority. Add a CAA record 0 issue "letsencrypt.org".

Which VPS for an HTTPS site?

A Let's Encrypt certificate costs nothing and uses almost no resources: the choice of VPS depends on the site itself. At ACLClouds, as of November 17, 2026, the VPS Mini (2 vCPU, 8 GB RAM, 40 GB storage) costs €4.99 per month with no commitment, or €3.99 per month with a one-year commitment, and runs nginx, PHP and a database for several sites. The preconfigured LEMP Web Server image already installs nginx, PHP-FPM, MariaDB and Certbot.

Quick check

  • dig +short example.com A returns the VPS IPv4.
  • curl -I https://example.com responds without a certificate error.
  • certbot certificates shows an expiry date about 90 days out.
  • certbot renew --dry-run ends with Congratulations, all simulated renewals succeeded.
  • systemctl list-timers certbot.timer shows a next run.

Frequently asked questions

Is Let's Encrypt really free?

Yes. Let's Encrypt is a nonprofit certificate authority, run by ISRG and funded by donations and sponsors. Certificates are free, with no limit as long as they are renewed, and browsers trust them just like a paid domain-validated certificate.

What is the difference between a free SSL certificate and a paid one?

The encryption is the same. A paid certificate can add organization validation (OV or EV), a longer validity period or a warranty, which some contractual requirements call for. For a site, an API or an admin interface, a domain-validated Let's Encrypt certificate is enough.

How do I renew a Let's Encrypt certificate manually?

Run certbot renew: only certificates close to expiry are renewed. To force a specific certificate, use certbot renew --cert-name example.com --force-renewal, sparingly because of the issuance limits.

Does the certificate work behind the Cloudflare proxy?

Yes. With the proxy enabled (orange cloud), set the Cloudflare SSL/TLS mode to Full (strict) so that Cloudflare verifies the VPS certificate. If HTTP validation fails through the proxy, switch to the Cloudflare DNS plugin, which does not depend on port 80.

Can I get a Let's Encrypt certificate for an IP address?

Yes, since January 2026, but only with the short-lived certificate profile (about 6 days), as an opt-in and with a recent client. For a site, a domain name or a free subdomain remains simpler.

How do I delete a certificate I no longer need?

First remove the ssl_certificate lines that reference it in nginx, or the Apache SSLCertificateFile directives, then run certbot delete --cert-name example.com. In the reverse order, the web server no longer restarts, because the file is gone.