Please excuse a very beginner question.
I'm having trouble understanding the nginx 'resolver' parameter and how it works. I have read the documentation, searched tutorials and posts (using keywords like resolver, nginx, and dns), and I'm still not sure how to apply resolver.
http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver
"Configures name servers used to resolve names of upstream servers into addresses...."
resolver ns1.myhost.com ns2.myhost.com;
But the examples point to
an internal/private IP address."An address can be specified as a domain name or IP address, and an optional port...."
resolver example.com
www.example.com;
(or resolver 12.34.56.78;
) but again, I see no such examples in the documentation. As a practical example, let's say — purely hypothetically :) — that I'm building a simple web server with a couple of server blocks on it.
Do I set 'resolver' to the IP of the server itself? Or an internal IP in the server's LAN? The documentation seems to suggest an internal IP (127.x.x.x or 10.x.x.x) — but how to set/determine what that IP is?
Resolve means which DNS server should nginx refer to when it has to resolve a external url. If you have a config like below
location / {
proxy_pass http://www.example.com/abc/def;
}
Now by default nginx
will pick your resolver from the host /etc/resolv.conf
and it may not be what you need. May be you want to use google DNS resolver for just this case. Then you will update your nginx config to below
location / {
resolver 8.8.8.8;
proxy_pass http://www.example.com/abc/def;
}
May be you are using a local DNS resolver to route within you local network then you may use something like below
location / {
resolver 192.168.11.10;
proxy_pass http://machineabc/abc/def;
}