Hello,
I am looking at how to use nginx’s resolver directive
(Module ngx_http_core_module) to
address this one issue i am facing. I have a host for which there is
already an entry in the system DNS resolver (verified using
nslookup/dig) but when i specify the same host in the proxy_pass
directive inside a location block, i get the following error thrown in
nginx.log
015/01/05 14:24:13 [error] 22560#0: *5 no resolver defined to resolve
…
Seems like nginx is not falling back to the system DNS resolver in case
the ‘resolver’ directive is not used. Isn’t this incorrect behaviour ?
From: “Kunal P.” [email protected]
To: [email protected]
Sent: Monday, January 5, 2015 3:04:52 PM
Subject: resolver directive doesn’t fallback to the system DNS resolver
Hello,
I am looking at how to use nginx’s resolver directive
(Module ngx_http_core_module) to
address this one issue i am facing. I have a host for which there is
already an entry in the system DNS resolver (verified using
nslookup/dig) but when i specify the same host in the proxy_pass
directive inside a location block, i get the following error thrown in
nginx.log
015/01/05 14:24:13 [error] 22560#0: *5 no resolver defined to resolve
…
Seems like nginx is not falling back to the system DNS resolver in case
the ‘resolver’ directive is not used. Isn’t this incorrect behaviour ?
Ok, I see the “no resolver defined to resolve www.example.com” message
when I make a request that matches that location.
Although i don’t want to use this resolver directive here and instead just want
nginx to use the system DNS resolver (from /etc/resolv.conf). Is there a way to
achieve this ?
Unless something has changed recently that I haven’t seen, my
understanding is:
if the hostname is known at start time, nginx will use the system
resolver
to resolve it, and will use the result forever
otherwise, you must use a “resolver” directive to tell nginx which name
servers to use for runtime resolution.
There is no default for “resolver”; if you want one to be used, you must
configure it explicitly. So I think the answer to your question is “no”.
(You could probably come up with a way to read /etc/resolv.conf when it
changes, and update the nginx config and reload it; but that’s a
“dynamic
reconfiguration” problem, not an “nginx dynamic reconfiguration”
problem.)
Now as per nginx AWS ELB name resolution with resolvers — Greg Taylor,
If you are running nginx as a proxy in front of An Amazon Web Services
Elastic Load Balancer (ELB) which is the case for me, it is not safe to
merely define an upstream using the hostname of ELB and call it a day.
Although i don’t want to use this resolver directive here and instead
just want nginx to use the system DNS resolver (from /etc/resolv.conf).
Is there a way to achieve this ?
Thanks
-Kunal
From: “Francis D.” [email protected]
To: [email protected]
Sent: Wednesday, January 7, 2015 3:14:17 PM
Subject: Re: resolver directive doesn’t fallback to the system DNS
resolver
On Mon, Jan 05, 2015 at 05:04:52PM -0600, Kunal P. wrote:
Hi there,
015/01/05 14:24:13 [error] 22560#0: *5 no resolver defined to resolve
…
Seems like nginx is not falling back to the system DNS resolver in case
the ‘resolver’ directive is not used. Isn’t this incorrect behaviour ?
(You could probably come up with a way to read /etc/resolv.conf when it
changes, and update the nginx config and reload it; but that’s a “dynamic
reconfiguration” problem, not an “nginx dynamic reconfiguration” problem.)
Yeah, I think it’s better for the nginx resolver to automatically use
whatever is defined in /etc/resolv.conf when the user does not
configure the “resolver” directive in her nginx.conf.
I’m already tired of seeing all those user questions regarding the
error message “no resolver defined to resolve …” over the years.
Alas.
Is there already a patch for this ?
I am not completely sure of how to make the nginx resolver (in
ngx_resolver.c) fallback to libresolv automatically and if this not
trivial enough, i just might read the resolvers from /etc/resolv.conf
and provide it to the ‘resolver’ directive. Any suggestions ?
Thanks
-Kunal
----- Original Message -----
From: “Yichun Z. (agentzh)” [email protected]
To: [email protected]
Sent: Wednesday, January 7, 2015 4:30:06 PM
Subject: Re: resolver directive doesn’t fallback to the system DNS
resolver
Hello!
On Wed, Jan 7, 2015 at 4:15 PM, Francis D. wrote:
(You could probably come up with a way to read /etc/resolv.conf when it
changes, and update the nginx config and reload it; but that’s a “dynamic
reconfiguration” problem, not an “nginx dynamic reconfiguration” problem.)
Yeah, I think it’s better for the nginx resolver to automatically use
whatever is defined in /etc/resolv.conf when the user does not
configure the “resolver” directive in her nginx.conf.
I’m already tired of seeing all those user questions regarding the
error message “no resolver defined to resolve …” over the years.
Alas.
----- Original Message -----
From: “Yichun Z. (agentzh)” [email protected]
To: [email protected]
Sent: Monday, January 12, 2015 2:19:08 PM
Subject: Re: resolver directive doesn’t fallback to the system DNS
resolver
Hello!
On Mon, Jan 12, 2015 at 1:48 PM, Kunal P. wrote:
Is there already a patch for this ?
AFAIK, the Tengine fork has a patch for this.
I am not completely sure of how to make the nginx resolver (in ngx_resolver.c)
fallback to libresolv automatically and if this not trivial enough, i just might
read the resolvers from /etc/resolv.conf and provide it to the ‘resolver’
directive. Any suggestions ?
I was not talking about falling back to libresolv because it is very
likely to block the nginx event loop or introduce extra OS threads for
no good. I was talking about extracing nameserver addresses
automatically from /etc/resolv.conf (or similar places in other exotic
operating systems) and feed them into nginx’s current nonblocking
resolver.
And yes, for now, the latter workaround should be the simplest for you
Is there already a patch for this ?
I am not completely sure of how to make the nginx resolver (in
ngx_resolver.c) fallback to libresolv automatically and if this not
Sorry am new to Lua but can you plz explain how this upstream status &
control will help with this issue. How can i query for the upstream ip
after every certain time interval and reconfigure nginx if there’s a
change detected ?
The reason for not using nginx’s resolver here is that i have to parse
the resolv.conf to get the nameservers which is not a clean solution as
there are still some linux distros that don’t use /etc/resolv.conf. This
should be OS & implementation independent. How to make this work
everywhere ?
Thanks
-Kunal
From: “itpp2012” [email protected]
To: [email protected]
Sent: Tuesday, January 13, 2015 1:58:32 AM
Subject: Re: resolver directive doesn’t fallback to the system DNS
resolver
kunalvjti Wrote:
Is there already a patch for this ?
I am not completely sure of how to make the nginx resolver (in
ngx_resolver.c) fallback to libresolv automatically and if this not
I am not completely sure of how to make the nginx resolver (in ngx_resolver.c)
fallback to libresolv automatically and if this not trivial enough, i just might
read the resolvers from /etc/resolv.conf and provide it to the ‘resolver’
directive. Any suggestions ?
I was not talking about falling back to libresolv because it is very
likely to block the nginx event loop or introduce extra OS threads for
no good. I was talking about extracing nameserver addresses
automatically from /etc/resolv.conf (or similar places in other exotic
operating systems) and feed them into nginx’s current nonblocking
resolver.
And yes, for now, the latter workaround should be the simplest for you