Not sure how to quickly summary this issue, so I will put my scenario in bulletpoints:
- Normal basic nginx install
- I only use https(443), so I removed all http(80) config
- When you start nginx (or
restart
it), the process seems to listen on port 80 as well (ss -tulp
) - When I add a config in
/etc/nginx/sites-enabled
with a listener on http(80) and then; - Reload nginx, using
systemctl reload nginx
(note: reload, not restart) - It does not work, as if nginx is still not listening for traffic on port 80
- If I run
systemctl restart nginx
it does work.
I noticed this, because LetsEncrypt couldn't renew my certificates.
After investigating the issue, I noticed the behaviour described above.
Because I had no nginx config listening on http(80), I think nginx just doesn't add any listeners or something when I start nginx (although port 80 was claimed by nginx)
And if Certbot then tries to renew my certificates, it would add a temporary http(80) config to the nginx config directory, presumably followed by a "reload" of nginx, rather than a restart (which is as expected and as it should)
But since nginx was started without http(80) config, it didn't process the traffic from LetsEncrypt to that temporary challenge config.
My solution was quite simple, to add a basic http(80) config block to nginx with only a return 404;
and restarted nginx.
After that, Certbot worked just fine and could renew all my certificates.
I was wondering if this is expected behaviour, or if this is a (known) bug in Nginx.
Thanks
Update:
nginx version: nginx/1.18.0
Debian 11 (Bullseye)