NGINX randomly stops working, required manual restart NGINX randomly stops working, required manual restart wordpress wordpress

NGINX randomly stops working, required manual restart


I encountered a similar issue when using nginx with certbot. I am hosting under Ubuntu 16.04 LTS and certbot is quite outdated (0.10.2).

As described here this version of certbot suffers an issue when emiting a certificate. The standard commands don't works, specific commands must be used.

Certbot comes with an auto updater that will renew certificates automatically. This updater fails to use the workaround and also fails to start the nginx service after operations.

What I did is to disable this service. There is a file at /etc/systemd/system/timers.target.wants/certbot.timer. Edit this file and comment the lines that enable the timer.

[Unit]Description=Run certbot twice daily[Timer]OnCalendar=*-*-* 00,12:00:00Persistent=true#[Install]#WantedBy=timers.target

Now you will have to renew the certificates manually.


How do you specify the upstream servers for nginx?

You should note that normally, http://nginx.org/r/proxy_pass caches the resolution of the domain names at startup time, unless you're using variables within proxy_pass together with the http://nginx.org/r/resolver directive.

What this means is that the resolution of the name may become stale and incorrect, resulting in the pages no longer loading.

The solution would be to use variables within proxy_pass, as well as specifying a resolver to use for ongoing resolutions.

Otherwise, the error log should still be useful to provide information on what's the cause of the downtime; make sure you're looking at the global http://nginx.org/r/error_log, not the error_log of the individual servers, which often won't have anything interesting in case of a serious issue affecting nginx as a whole.