Thanks for filing this bug in Ubuntu.

There are similar cases out there with other services, when a specific
IP address is selected for the service to bind to. openssh, for example,
has this bug upstream: https://bugzilla.mindrot.org/show_bug.cgi?id=2512

A few solutions, or workarounds, exist for this. The only one that seems to 
work for all use cases is to use the IP_FREEBIND socket option:
       IP_FREEBIND (since Linux 2.4)
              If enabled, this boolean option allows binding to an IP address 
that is nonlocal or does not (yet) exist.  This permits listening on a socket, 
without requiring the underlying network  inter‐
              face  or  the specified dynamic IP address to be up at the time 
that the application is trying to bind to it.  This option is the per-socket 
equivalent of the ip_nonlocal_bind /proc interface
              described below.

That requires an upstream change, however.

In the meantime, users affected by this are probably better off by
having nginx starting later in the boot process by adding a dependency
to network-online.target. It will likely make the boot slower, though,
that's why it's not a good solution to be applied generally.

You can try this perhaps:
sudo systemctl edit nginx.service

Then in the empty file that opens, type:
[Unit]
After=network-online.target
Requires=network-online.target

Then save. You can view your addition in the output of this command now:

sudo systemctl cat nginx.service

There appear to be more fine-grained ways of achieving this, like
specifying which interface to wait for.
https://www.freedesktop.org/software/systemd/man/systemd-networkd-wait-
online.html documents something like that, but I haven't tried it.


** Bug watch added: OpenSSH Portable Bugzilla #2512
   https://bugzilla.mindrot.org/show_bug.cgi?id=2512

-- 
You received this bug notification because you are a member of Ubuntu
Server, which is subscribed to nginx in Ubuntu.
https://bugs.launchpad.net/bugs/1818574

Title:
  Nginx cannot bind static IPv6 address on boot

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/1818574/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs

Reply via email to