Hello,

I know what the problem is.

The problem is that nginx starts before all network interfaces are upped up. I looked through all nginx unit files (nginx-common debian package) and found that all versions, including Ubuntu 22.04, have incorrect After & Wants.

All versions from the package specify After=network.target, but if you study this network.target, it does not guarantee that the entire network on the device is already configured. It is correct to use network-online.target. Moreover, it is also recommended by the nginx developers themselves:

https://www.nginx.com/resources/wiki/start/topics/examples/systemd/

As a temporary solution, I recommend doing so until it is fixed in the package nginx-common itself:

$ sudo systemctl edit nginx.service

To insert there:

[Unit]
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

Best regards, Perlover

Reply via email to