Welcome! Log In Create A New Profile

Advanced

Re: Workaround of race condition between systemd and nginx.

Daniel K.
December 30, 2015 01:30PM
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@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.

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Workaround of race condition between systemd and nginx.

Gena Makhomed 584 December 30, 2015 08:46AM

Re: Workaround of race condition between systemd and nginx.

Jim Popovitch 217 December 30, 2015 09:52AM

Re: Workaround of race condition between systemd and nginx.

Gena Makhomed 443 December 30, 2015 10:52AM

Re: Workaround of race condition between systemd and nginx.

Jim Popovitch 228 December 30, 2015 11:10AM

Re: Workaround of race condition between systemd and nginx.

Gena Makhomed 214 December 30, 2015 11:52AM

Re: Workaround of race condition between systemd and nginx.

Jim Popovitch 289 December 30, 2015 12:10PM

Re: Workaround of race condition between systemd and nginx.

Gena Makhomed 272 December 30, 2015 12:46PM

Re: Workaround of race condition between systemd and nginx.

Jim Popovitch 281 December 30, 2015 01:00PM

Re: Workaround of race condition between systemd and nginx.

Gena Makhomed 203 December 30, 2015 01:48PM

Re: Workaround of race condition between systemd and nginx.

Daniel K. 218 December 30, 2015 01:30PM

Re: Workaround of race condition between systemd and nginx.

Das, Jagannath 245 December 30, 2015 01:50PM

Re: Workaround of race condition between systemd and nginx.

Gena Makhomed 245 December 30, 2015 02:04PM

Re: Workaround of race condition between systemd and nginx.

Gena Makhomed 227 December 30, 2015 01:56PM

Re: Workaround of race condition between systemd and nginx.

Daniel K. 267 December 30, 2015 03:42PM

Re: Workaround of race condition between systemd and nginx.

Artem S. Povaluhin 207 December 30, 2015 05:46PM

Re: Workaround of race condition between systemd and nginx.

Gena Makhomed 273 December 31, 2015 12:06AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 100
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready