Free HTTPS for your site with Caddy or Certbot
Two free ways to put a padlock on your site: Caddy does it by itself, Certbot adds it to Nginx. Step by step, for a Linux server.
· 2 min read
Browsers warn people away from sites without HTTPS, and search engines prefer sites that have it. The good news: certificates are free, thanks to Let's Encrypt, and the tools below get and renew them for you.
Before you start, make sure your domain already points to your server (an A or AAAA record) and that ports 80 and 443 are open in your firewall. The certificate authority checks that you control the name by reaching your server on it.
Option 1: Caddy (the easiest)
Caddy is a web server that gets and renews certificates by itself. If your app runs on port 3000, this is the whole configuration, in a file called Caddyfile:
example.com {
reverse_proxy localhost:3000
}
Start Caddy (or reload it with caddy reload) and it fetches a certificate for example.com, sends plain HTTP visitors to HTTPS, and renews the certificate before it expires. For a static site, replace the reverse_proxy line with root * /var/www/site and file_server.
You can list several sites in one Caddyfile, one block each. That is how we run many small sites on a single server.
Option 2: Nginx with Certbot
If you already use Nginx, Certbot adds certificates to it. On Ubuntu or Debian:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com
Certbot finds the matching server block, gets the certificate, and updates the Nginx configuration. It also installs a timer that renews certificates automatically. You can test renewal at any time:
sudo certbot renew --dry-run
Common problems
- The check fails: the name doesn't point to this server yet, or port 80 is blocked. Check the record with
dig +short example.comand your firewall rules. - Too many requests: Let's Encrypt limits how often you can ask for the same certificate. Fix the cause first, then try again later instead of retrying in a loop.
- Mixed content warnings: the page is on HTTPS but loads pictures or scripts over
http://. Change those links tohttps://.
Which one to pick
For a new server, Caddy is simpler and has fewer moving parts. If you already have a working Nginx setup, Certbot fits into it without changing much. Both give you the same free, trusted certificate.
No name yet? Point a free subdomain like you.softwaretrinkets.com at your server and give it HTTPS the same way.