I imagine most people already know this, but posting in case it does help someone. I have a little nginx install that I run on an SER beelink, that mirrors the one I always spam here, srobb.net. Anyway, it uses letsencrypt and runs nginx. I had never figured out how to get it to work right--I always had to stop nginx, and renew the cert. Today, while bored, decided to web search it a bit. Anyway, assuming one installs the py312-certbot-nginx plugin, one can do it with a cron job.
(Most of you know this, but the problem would be that certbot couldn't renew because nginx was using port 80. Therefore, it had to be stopped for the renewal.)
For any real beginners unfamiliar with cron, the time and day are arbitrary. The trick is the renew and the --nginx part.
Anyway, though I feel foolish not having learned this earlier, better late than never. It was something I kept planning to investigate and always forgetting, then I'd see my cert expired and stop nginx, renew the cert and start nginx again.
(Most of you know this, but the problem would be that certbot couldn't renew because nginx was using port 80. Therefore, it had to be stopped for the renewal.)
Code:
0 5 * * sun /usr/local/bin/certbot renew --nginx >> /var/log/certbot >> /var/log/letsencrypt/letsencrypt.log
Anyway, though I feel foolish not having learned this earlier, better late than never. It was something I kept planning to investigate and always forgetting, then I'd see my cert expired and stop nginx, renew the cert and start nginx again.