[Ubuntu 16.04] nginx won't start on boot while network does not up yet

Bug #1666368 reported by stephon on 2017-02-21
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nginx (Ubuntu)
Undecided
Unassigned

Bug Description

Hi Ubuntu bug report,

After installing nginx and setup done, nginx works normally by "systemctl restart nginx.service"

But nginx won't start on boot.

After running "systemctl status nginx.service", I found that network & dns lookup have not done yet on boot.

nginx should be started after network online and dns lookup working normally, instead of after network.target.

In the attachment, I modified /lib/systemd/system/nginx.service to require network-online.target & nss-lookup.target works normally.

Would you like to merge the patch to nginx package?

Thanks a lot.
--
Stephon Chen

The attachment "Patch for /lib/systemd/system/nginx.services, let nginx start requiring network-online and nss-lookup work normally." seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Simon Déziel (sdeziel) wrote :

@stephon, the default vhost provided by the package doesn't produce a configuration that requires DNS resolution to start so could you share your nginx/vhost config? Please also share the journalctl entries for nginx.

Changed in nginx (Ubuntu):
status: New → Incomplete
Simon Déziel (sdeziel) wrote :

Also, if your local config does indeed require DNS to be resolvable when nginx starts, I see 2 possible fixes/workarounds for you.

1) you could use a systemd drop-in snippet to tune the startup order like you did in your patch.

2) you could put the IP(s) and DNS name(s) under /etc/hosts. This will only work for static IPs though.

stephon (stephon) wrote :

Hi @Simon,

From above comment, nginx default package in ubuntu just setup for IP-based vhost only.

Since my environment needs domain-based vhosts config, I have adopted systemd drop-in snipped like 1) already.

Thanks for your information, and this ticket can be closed.

Thomas Ward (teward) wrote :

The SystemD spec currently says daemons should seek network.target, not network-online.target.

We will not be altering the SystemD specs for the package or its SystemD unit at this time. Providing the SystrmD drop in snippets is the proper approach as the default daemon behavior on a clean install does not need network-online.target.

Changed in nginx (Ubuntu):
status: Incomplete → Won't Fix
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers