I have found a scenario where the solution I proposed is not necessarily sufficient to allow nginx to start on boot.
IF
your server does not know its IPv4 and IPv6 address before starting to boot up, because it is using an ‘elastic IP service’ (such as from AWS)
THEN
the network-online.target solution is not guaranteed to work.
You may be using an ‘elastic IP service’ without even realising it or being specically told.
I have found the following works:
Add the following two lines into /etc/sysctl.conf