Workaround of race condition between systemd and nginx.
Daniel K.
dk at syse.no
Wed Dec 30 18:28:38 UTC 2015
On 12/30/2015 03:50 PM, Gena Makhomed wrote:
> On 30.12.2015 16:51, Jim Popovitch wrote:
>> On Dec 30, 2015 8:46 AM, "Gena Makhomed" <gmm at csdoc.com> wrote:
>>> Workaround of race condition between systemd and nginx.
>>>
>>> Just replace network.target with network-online.target in systemd unit
>>> files.
>>> More details:
>>> http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
>>
>> From that page, wrt network-online.target:
>>
>> "It is strongly recommended not to pull in this target too liberally: for
>> example network server software should generally not pull this in (since
>> server software generally is happy to accept local connections even before
>> any routable network interface is up), it's primary purpose is network
>> client software that cannot operate without network"
>
> nginx now requires configured and up network, before starting daemon.
> Replace network.target with network-online.target is easy workaround.
Actually it does not require that at all.
It would be more helpful if you posted your config files, but from your
log file i gather they look something like:
server {
listen 172.22.22.202:80;
[...]
}
And that, due to using systemd, the nginx service gets started before
the network-interface have been configured with the IP address shown.
Two ways you can work around this issue comes to mind.
1) Allow non-local binds
# echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind
Put 'net.ipv4.ip_nonlocal_bind = 1' in /etc/sysctl.conf to make it stick.
2) Configure nginx to listen to *:80
Add this to your config files somewhere.
server {
listen 80;
}
to your config files somewhere, and nginx will listen to 0.0.0.0:80
instead of every IP address you mention.
Hope that helps,
Daniel K.
More information about the nginx-devel
mailing list