<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>
<div>How to reproduce this issue?</div>
<div>
<div id="MAC_OUTLOOK_SIGNATURE"></div>
</div>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:12pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>"Daniel K." <<a href="mailto:dk@syse.no">dk@syse.no</a>><br>
<span style="font-weight:bold">Reply-To: </span>"<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a>" <<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a>><br>
<span style="font-weight:bold">Date: </span>Wednesday, December 30, 2015 at 11:58 PM<br>
<span style="font-weight:bold">To: </span>"<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a>" <<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a>><br>
<span style="font-weight:bold">Subject: </span>Re: Workaround of race condition between systemd and nginx.<br>
</div>
<div><br>
</div>
<div>
<div>
<div>On 12/30/2015 03:50 PM, Gena Makhomed wrote:</div>
<blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: #b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;">
<div>On 30.12.2015 16:51, Jim Popovitch wrote:</div>
<blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: #b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;">
<div>On Dec 30, 2015 8:46 AM, "Gena Makhomed" <<a href="mailto:gmm@csdoc.com">gmm@csdoc.com</a>> wrote:</div>
<blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: #b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;">
<div>Workaround of race condition between systemd and nginx.</div>
<div><br>
</div>
<div>Just replace network.target with network-online.target in systemd unit</div>
<div>files.</div>
<div>More details:</div>
<div><a href="http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/">http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/</a></div>
</blockquote>
<div><br>
</div>
<div>From that page, wrt network-online.target:</div>
<div><br>
</div>
<div>"It is strongly recommended not to pull in this target too liberally: for</div>
<div>example network server software should generally not pull this in (since</div>
<div>server software generally is happy to accept local connections even before</div>
<div>any routable network interface is up), it's primary purpose is network</div>
<div>client software that cannot operate without network"</div>
</blockquote>
<div></div>
<div>nginx now requires configured and up network, before starting daemon.</div>
<div>Replace network.target with network-online.target is easy workaround.</div>
</blockquote>
<div><br>
</div>
<div>Actually it does not require that at all.</div>
<div><br>
</div>
<div>It would be more helpful if you posted your config files, but from your</div>
<div>log file i gather they look something like:</div>
<div><br>
</div>
<div>server {</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>listen<span class="Apple-tab-span" style="white-space:pre">
</span>172.22.22.202:80;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>[...]</div>
<div>}</div>
<div><br>
</div>
<div>And that, due to using systemd, the nginx service gets started before</div>
<div>the network-interface have been configured with the IP address shown.</div>
<div><br>
</div>
<div><br>
</div>
<div>Two ways you can work around this issue comes to mind.</div>
<div><br>
</div>
<div>1) Allow non-local binds</div>
<div><br>
</div>
<div># echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind</div>
<div><br>
</div>
<div>Put 'net.ipv4.ip_nonlocal_bind = 1' in /etc/sysctl.conf to make it stick.</div>
<div><br>
</div>
<div><br>
</div>
<div>2) Configure nginx to listen to *:80</div>
<div><br>
</div>
<div>Add this to your config files somewhere.</div>
<div><br>
</div>
<div>server {</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>listen<span class="Apple-tab-span" style="white-space:pre">
</span>80;</div>
<div>}</div>
<div><br>
</div>
<div>to your config files somewhere, and nginx will listen to 0.0.0.0:80</div>
<div>instead of every IP address you mention.</div>
<div><br>
</div>
<div><br>
</div>
<div>Hope that helps,</div>
<div><br>
</div>
<div><br>
</div>
<div>Daniel K.</div>
<div><br>
</div>
<div>_______________________________________________</div>
<div>nginx-devel mailing list</div>
<div><a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a></div>
<div><a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a></div>
<div><br>
</div>
</div>
</div>
</span>
</body>
</html>