Nginx boot issues with centos7

Greetings,

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.

[[email protected] ~]$ nginx -v
nginx version: nginx/1.8.0

[[email protected] ~]$ cat /etc/nginx/conf.d/default.conf
server {
location / {
proxy_pass http://web01.mycorp.lan:8080;
}
}

When the system boots nginx doesn’t start automatically and the
logs indicate that it wasn’t able to make a DNS query.

[[email protected] ~]$ sudo systemctl status nginx.service
nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled)
Active: failed (Result: exit-code) since Wed 2015-04-29 11:11:42 CDT;
1min 30s ago
Docs: http://nginx.org/en/docs/
Process: 1141 ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
(code=exited, status=1/FAILURE)
Apr 29 11:11:42 nginx.mycorp.lan nginx[1141]: nginx: [emerg] host not
found
in upstream "web01.mycorp.lan…f:38
Apr 29 11:11:42 nginx.mycorp.lan nginx[1141]: nginx: configuration file
/etc/nginx/nginx.conf test failed
Apr 29 11:11:42 nginx.mycorp.lan systemd[1]: nginx.service: control
process
exited, code=exited status=1
Apr 29 11:11:42 nginx.mycorp.lan systemd[1]: Failed to start nginx -
high
performance web server.
Apr 29 11:11:42 nginx.mycorp.lan systemd[1]: Unit nginx.service entered
failed state.

This is the default configuration file for nginx.service in systemd.

[[email protected] ~]$ sudo cat /usr/lib/systemd/system/nginx.service
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target

I’ve determined that adding network-online.target resolves the problem
and
allows nginx to start properly upon boot.

[[email protected] ~]$ sudo cat /usr/lib/systemd/system/nginx.service
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target network-online.target remote-fs.target
nss-lookup.target
Requires=network-online.target

Is this a problem that can be addressed by the nginx team?

Many thanks.

Aidan

Hello Aidan,

On 29/04/2015 19:33, Aidan Scheller wrote:

server {
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled)
process exited, code=exited status=1
After=network.target remote-fs.target nss-lookup.target

Is this a problem that can be addressed by the nginx team?

I believe the proper way to fix that issue is:

systemctl enable systemd-networkd-wait-online.service

I am reluctant in adding this as a dependancy for the default package
because of the issues described in
http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
(notably, a possible 90s delay).


Konstantin P.

On 29/04/2015 19:49, Konstantin P. wrote:

nginx version: nginx/1.8.0

Apr 29 11:11:42 nginx.mycorp.lan nginx[1141]: nginx: configuration file
[[email protected] ~]$ sudo cat /usr/lib/systemd/system/nginx.service
After=network.target network-online.target remote-fs.target
nss-lookup.target
Requires=network-online.target

Is this a problem that can be addressed by the nginx team?

I believe the proper way to fix that issue is:

systemctl enable systemd-networkd-wait-online.service

Or, if one uses NetworkManager:

systemctl enable NetworkManager-wait-online.service


Konstantin P.

Thank you, Konstantin! I’ll investigate those.

Best regards,

Aidan

On Wed, Apr 29, 2015 at 11:51 AM, Konstantin P. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs