Certbot is the official Let’s Encrypt client: a single command issues a free, auto-renewing TLS certificate for your domain. It can edit your Nginx config in-place to enable HTTPS, install proper TLS settings, and handle the 90-day auto-renewal in the background.
Solve the HTTP-01 challenge by serving a token over port 80.
Issue the certificate into /etc/letsencrypt/live/<domain>/.
Patch your existing Nginx vhost: add the listen 443 ssl, ssl_certificate, ssl_certificate_key directives, and an HTTP→HTTPS redirect (that is why its recommended to write only the HTTP directive in nginx: certbot will do the rest).
Reload Nginx.
Wildcard certificates
Attention
certbot --nginx cannot issue wildcard certificates (e.g. *.example.com).
The Nginx plugin uses the HTTP-01 challenge, which validates only the exact hostname being requested. Wildcards require the DNS-01 challenge, which proves control of the entire DNS zone by writing a TXT record.
For a wildcard you need a DNS plugin matching your provider (Cloudflare, Route53, DigitalOcean, OVH…):
Note the certonly: with wildcards Certbot only issues the cert, it won’t auto-edit the Nginx vhost. You wire the ssl_certificate paths into Nginx yourself. Renewal still works automatically through certbot.timer because the credentials and challenge are saved in the renewal config.
If your DNS provider isn’t in the official plugin list, the alternatives are --manual --preferred-challenges dns (no auto-renewal) or acme.sh with a custom DNS hook.
What Certbot adds to the vhost
If you have a nginx vhost with only the HTTP directive written, for example:
server { listen 80; listen [::]:80; server_name example.com www.example.com; root /var/www/example; # filesystem root for static files index index.html; location / { try_files $uri $uri.html $uri/ =404; }}
After you run certbot --nginx -example.com, your vhost will look roughly like this:
# HTTP -> HTTPS redirect (managed by Certbot)server { if ($host = example.com) { return 301 https://$host$request_uri; } listen 80; listen [::]:80; server_name example.com; return 404;}# HTTPS: the original server, now with TLSserver { server_name example.com; root /var/www/example; index index.html; location / { try_files $uri $uri.html $uri/ =404; } listen [::]:443 ssl; # managed by Certbot listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot}
The lines with # managed by Certbot are owned by Certbot: touch them only if you know what you’re doing.
3. Auto-renewal
On systemd-based distros (Ubuntu 16.04+, Debian 9+) the package installs a certbot.timer that runs twice a day and renews any cert within 30 days of expiry. Verify with:
systemctl list-timers | grep certbot# certbot.timer ... certbot.servicesystemctl status certbot.timer
Test the renewal flow without actually renewing:
sudo certbot renew --dry-run
If something looks off, the renewal config for each domain lives in /etc/letsencrypt/renewal/<domain>.conf:
The wiki you’re reading runs the exact setup described above.
The vhost lives in /etc/nginx/sites-available/wiki.farnetiandrea.it (enabled via a symlink in /etc/nginx/sites-enabled/).
Example: wiki.farnetiandrea.it
server { server_name wiki.farnetiandrea.it; root ~/wiki/public; index index.html; location / { try_files $uri $uri.html $uri/ =404; } listen [::]:443 ssl; # managed by Certbot listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/wiki.farnetiandrea.it/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/wiki.farnetiandrea.it/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;}server { if ($host = wiki.farnetiandrea.it) { return 301 https://$host$request_uri; } listen 80; listen [::]:80; server_name wiki.farnetiandrea.it; return 404;}
The renewal config in /etc/letsencrypt/renewal/wiki.farnetiandrea.it.conf declares authenticator = nginx, installer = nginx, so Certbot reuses the Nginx plugin both to validate and to install renewed certs directly in Nginx.
The authenticator = nginx and installer = nginx lines tell Certbot to reuse the Nginx plugin both to validate the http-01 challenge (served from the Nginx vhost) and to install renewed certificates directly into the Nginx config.