How did nginx resolve names?

Francis Daly francis at daoine.org
Sun Mar 7 11:24:06 UTC 2021


On Fri, Mar 05, 2021 at 03:09:34PM +0100, basti wrote:

Hi there,

> Today I had the problem, that nginx run into "504 Gateway Time-out" when the
> first nameserver in /etc/resolv.conf did not answer.
> 
> The php application is query some names (db-server for example).
> 
> Did nginx use nsswitch?

Very roughly: if nginx sees a hostname that matters in the config file,
nginx will use the system resolver at start-up time to turn that into
an IP address, and will never resolve it again.

If nginx instead sees a hostname at request-processing time, it will
use whatever "resolver" was configured in the nginx config file.

http://nginx.org/r/resolver

nginx-at-startup does not use nsswitch directly; it uses your system
resolver, and *that* might use nsswitch -- nginx does not care.

nginx-at-request does not use anything from the system resolver.

And: if the issue is that your php script is doing some name resolution,
then nginx will not be involved in that -- your php will do whatever
your php is configured to do -- probably something that your favourite
search engine will mention when requesting "php hostname resolution".

Cheers,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list