Nginx doesn't run on startup - Ubuntu 18.04

1 post / 0 new
#1 Sat, 11/24/2018 - 23:55
trenzterra

Nginx doesn't run on startup - Ubuntu 18.04

After many months, I'm happy to report that the latest version of Virtualmin seems to work properly with netplan and Ubuntu 18.04.

However, I am still facing a strange bug, where Nginx does not boot on startup. This is on a Digitalocean droplet, IPV6 and private networking enabled. It happens after Nginx is installed and after creating and IPv6 enabled virtual server.

I've managed to trace down the issue, and it seems related to Nginx starting up too soon, which seems to be attributable to the fact that cloud-init no longer runs after Virtualmin/ Webmin is installed. As a result, network.target is brought forward in the boot process and Nginx starts prematurely, before IPv6 is ready and Nginx fails to start.

If I setup a clean LEMP installation (without Virtualmin), cloud-init loads correctly and Nginx waits until the network is up before launching.

Attached are my systemd-analyze results:

https://www.dropbox.com/s/0nypxv17oxxsgnh/correct.svg?dl=0 -- LEMP installation. Notice nginx.service starts after cloud-init and after wait-online has completed.

https://www.dropbox.com/s/os23xokqwydhw4n/boot.svg?dl=0 -- With Virtualmin installed, NGINX starts right at network-target. There is no cloud-init process delaying Nginx's start. It fails because Nginx starts before IPv6 is ready.

I have tried this multiple times with the same result. The only fix that works reliably as of now is to change After=network.target to After=network-online.target in nginx.service configuration.

If this issue could be fixed, I think it's safe to say that Virtualmin on 18.04 is finally compatible.