Managing your own SSL certificates (without Cloudflare)
Most installs do not need this page. If your domains are proxied through Cloudflare, Cloudflare provides SSL for every domain and you can skip everything below. See Installing FunnelFlux.
Use this page when:
- a domain’s DNS is not on Cloudflare, or you do not want it proxied, and
- you want visitors to get HTTPS on that domain without a certificate warning.
How it works
Section titled “How it works”The installer sets up one catch-all Nginx site, /etc/nginx/sites-available/funnelflux.
It answers on HTTP and HTTPS for any domain, using a self-signed certificate for HTTPS.
Browsers show a warning for that certificate, so a domain that visitors reach directly needs a real one.
Leave the catch-all site alone. For each domain that needs its own certificate, add a separate Nginx site for that domain and let Certbot install a free Let’s Encrypt certificate into it. Every other domain keeps using the catch-all.
Do not run Certbot against the catch-all site itself.
Its server_name _; line does not match any domain, so Certbot stops with Could not automatically find a matching server block.
Before you start
Section titled “Before you start”- The domain’s A record must point straight at the server IP.
Check it with
dig +short tracker.example.com; it must return the server IP, not Cloudflare addresses. - If the domain is on Cloudflare but you want your own certificate, set the record to DNS only (grey cloud) first.
- Ports 80 and 443 must be open. The installer’s firewall already allows both.
Add a certificate for one domain
Section titled “Add a certificate for one domain”Replace tracker.example.com with your domain in every command.
-
SSH into the server as
root. -
Create a site for the domain from a copy of the catch-all site, and enable it:
Terminal window D=tracker.example.comsudo cp /etc/nginx/sites-available/funnelflux /etc/nginx/sites-available/$Dsudo sed -i "s/server_name _;/server_name $D;/" /etc/nginx/sites-available/$Dsudo ln -s /etc/nginx/sites-available/$D /etc/nginx/sites-enabled/sudo nginx -t && sudo systemctl reload nginx -
Install Certbot and its Nginx plugin:
Terminal window sudo apt-get install -y certbot python3-certbot-nginx -
Request and install the certificate:
Terminal window sudo certbot --nginx -d tracker.example.comCertbot asks for an email address for expiry notices and asks you to accept the Let’s Encrypt terms. It replaces the self-signed certificate in the new site and adds an HTTP-to-HTTPS redirect for this domain only.
-
Check that HTTPS works without a warning:
Terminal window curl -I https://tracker.example.com
Repeat these steps for each domain that needs its own certificate.
To put several names on one certificate, list them all on both server_name lines of the new site, separated by spaces, and pass a -d flag for each name to Certbot.
Renewing certificates
Section titled “Renewing certificates”Let’s Encrypt certificates expire after 90 days. The Ubuntu Certbot package installs a systemd timer that renews them automatically, so you do not need a cron job.
Check the timer and test renewal:
systemctl list-timers certbot.timersudo certbot renew --dry-runRemoving a domain
Section titled “Removing a domain”To stop using your own certificate for a domain, disable its site and reload Nginx. The domain then falls back to the catch-all site.
sudo rm /etc/nginx/sites-enabled/tracker.example.comsudo nginx -t && sudo systemctl reload nginxsudo certbot delete --cert-name tracker.example.com
