brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: certbot --nginx gets a certificate and wires it into your server block

Nginx
~/tips/tip-certbot-nginx-plugin

sudo certbot --nginx -d example.com -d www.example.com

Get a Let's Encrypt certificate and enable it in nginx with one command

Getting a certificate is one job and editing the nginx config to use it is another. Certbot can do both.

With the nginx plugin installed, run:

sudo certbot --nginx -d example.com -d www.example.com

Certbot finds the matching server block, proves you control the domain through a temporary challenge, stores the certificate under /etc/letsencrypt/live/, and adds the ssl_certificate lines to your config. It also redirects HTTP to HTTPS by default and reloads nginx. Add --no-redirect if you don’t want the redirect.

Check that renewal works before you rely on it: sudo certbot renew --dry-run. Most packages install a timer that renews certificates in the background.

A caveat: certbot edits your config files. Look at the result with sudo nginx -t and read the changes, especially if you manage the config by hand or with templates. If you’d rather keep control, use certbot certonly --nginx and write the SSL lines yourself.

Further reading: Certbot instructions

Going deeper: Run degoog on Unraid as your own search page, compared with SearXNG and 4get

More Nginx tips /data/nginx/custom/server_redirect.conf map $http_upgrade $connection_upgrade { proxy_intercept_errors on; proxy_redirect http://localhost:3000/ /app/; sub_filter 'http://127.0.0.1:8081/' 'https://example.com/app/'; All Nginx tips (50) All topics

Link