Free HTTPS on NGINX with Let's Encrypt and Certbot (Multiple Domains)
Add free TLS certificates to NGINX with Certbot: HTTP-01 and DNS-01 challenges, multiple domains, wildcard certs, auto-renewal and a hardened TLS config.
Published November 27, 2026
There is no reason to run a website over plain HTTP any more. Let's Encrypt issues free, automatically renewable TLS certificates, and Certbot can configure NGINX for you in one command. This guide covers how the validation works, how to secure several sites on one server, wildcard certificates, and making sure renewals never silently fail.
The concept
Let's Encrypt is a certificate authority that uses the ACME protocol to prove you control a domain. In the HTTP-01 challenge, Certbot places a token file under /.well-known/acme-challenge/ on your site and Let's Encrypt fetches it over port 80. In the DNS-01 challenge, you prove control by creating a TXT record, which is the only way to obtain wildcard certificates such as *.example.com.
Certificates are valid for 90 days by design, which forces automation. Certbot installs a systemd timer (or cron job) that tries renewal twice a day and renews certificates within 30 days of expiry. With the nginx plugin, Certbot also edits your server blocks to add the certificate paths and an HTTP-to-HTTPS redirect.
How HTTP-01 validation works
Challenge types
| Challenge | Needs | Wildcards | Best for |
|---|---|---|---|
| HTTP-01 | Port 80 reachable, DNS points at server | No | Most single-server sites |
| DNS-01 | API access to your DNS provider | Yes | Wildcards, internal servers, many subdomains |
| TLS-ALPN-01 | Port 443 reachable | No | When port 80 is blocked (not supported by Certbot nginx plugin) |
Issuing a certificate
What the HTTPS server block ends up looking like
Certbot inserts lines marked "# managed by Certbot". This is equivalent hand-written config with modern defaults.
server {
listen 80;
server_name example.com www.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
http2 on;
server_name example.com www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_session_cache shared:SSL:10m;
add_header Strict-Transport-Security "max-age=31536000" always;
root /var/www/example;
}Practical examples
Separate certificate per site
Run Certbot once per site so each server block has its own certificate.
sudo certbot --nginx -d blog.example.com
sudo certbot --nginx -d shop.example.net -d www.shop.example.net
sudo certbot certificatesWildcard certificate with DNS-01 (Cloudflare example)
Needs the DNS plugin and an API token stored with 600 permissions.
sudo apt install python3-certbot-dns-cloudflare
sudo certbot certonly --dns-cloudflare \
--dns-cloudflare-credentials /root/.secrets/cloudflare.ini \
-d example.com -d '*.example.com'Reload NGINX after every renewal
A deploy hook runs only when a certificate actually renews.
echo -e '#!/bin/sh\nsystemctl reload nginx' | sudo tee /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh
sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh
systemctl list-timers | grep certbotCommon mistakes
- DNS not yet pointing at the server when running Certbot, so validation fails.
- A firewall or a redirect rule blocking /.well-known/acme-challenge/ on port 80.
- Hitting Let's Encrypt rate limits by retrying failed issuance in a loop; test with --staging first.
- Never running certbot renew --dry-run, then discovering a broken renewal when the certificate expires.
- Copying certificates elsewhere instead of referencing /etc/letsencrypt/live, so renewed files are never picked up.
Key takeaways
- Let's Encrypt proves domain control with HTTP-01 (port 80) or DNS-01 (TXT record).
- certbot --nginx issues certificates and updates server blocks automatically.
- Wildcard certificates require DNS-01.
- Verify renewal with --dry-run and reload NGINX with a deploy hook.
FAQ
Can one certificate cover multiple domains?
Yes. A SAN certificate can list up to 100 names. Use separate certificates when sites belong to different clients so one cannot see the others' names.
Do I still need port 80 open after HTTPS works?
For HTTP-01 renewals, yes. Keep port 80 open and redirect everything except the ACME challenge path to HTTPS.
Is a free certificate less secure than a paid one?
No. Encryption strength is identical. Paid certificates may add organisation validation or warranties, but browsers treat domain-validated certificates the same.