<div dir="ltr"><div>Greetings,</div><div><br></div><div>It appears that nginx has difficulties starting automatically in CentOS 7 when it needs to resolve DNS names in the configuration.  I'm attributing this to systemd.  Nginx stable was installed from packages.</div><div><br></div><div>[admin@nginx ~]$ nginx -v<br>nginx version: nginx/1.8.0<br></div><div><br></div><div>[admin@nginx ~]$ cat /etc/nginx/conf.d/default.conf</div><div>server {</div><div>        location / {<br>                proxy_pass <a href="http://web01.mycorp.lan:8080">http://web01.mycorp.lan:8080</a>;<br>        }</div><div>}</div><div><br></div><div>When the system boots nginx doesn't start automatically and the logs indicate that it wasn't able to make a DNS query.</div><div><br></div><div>[admin@nginx ~]$ sudo systemctl status nginx.service<br>nginx.service - nginx - high performance web server<br>   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled)<br>   Active: failed (Result: exit-code) since Wed 2015-04-29 11:11:42 CDT; 1min 30s ago<br>     Docs: <a href="http://nginx.org/en/docs/">http://nginx.org/en/docs/</a><br>  Process: 1141 ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)</div><div>Apr 29 11:11:42 nginx.mycorp.lan nginx[1141]: nginx: [emerg] host not found in upstream "web01.mycorp.lan...f:38<br>Apr 29 11:11:42 nginx.mycorp.lan nginx[1141]: nginx: configuration file /etc/nginx/nginx.conf test failed<br>Apr 29 11:11:42 nginx.mycorp.lan systemd[1]: nginx.service: control process exited, code=exited status=1<br>Apr 29 11:11:42 nginx.mycorp.lan systemd[1]: Failed to start nginx - high performance web server.<br>Apr 29 11:11:42 nginx.mycorp.lan systemd[1]: Unit nginx.service entered failed state.</div><div><br></div><div>This is the default configuration file for nginx.service in systemd.</div><div><br></div><div>[admin@nginx ~]$ sudo cat /usr/lib/systemd/system/nginx.service<br>Description=nginx - high performance web server<br>Documentation=<a href="http://nginx.org/en/docs/">http://nginx.org/en/docs/</a><br>After=network.target remote-fs.target nss-lookup.target</div><div><br></div><div>I've determined that adding network-online.target resolves the problem and allows nginx to start properly upon boot.</div><div><br></div><div>[admin@nginx ~]$ sudo cat /usr/lib/systemd/system/nginx.service<br>Description=nginx - high performance web server<br>Documentation=<a href="http://nginx.org/en/docs/">http://nginx.org/en/docs/</a><br>After=network.target network-online.target remote-fs.target nss-lookup.target<br>Requires=network-online.target</div><div><br></div><div>Is this a problem that can be addressed by the nginx team?</div><div><br></div><div>Many thanks.</div><div><br></div><div>Aidan<br><br></div></div>