Nginx need to manually specify resolver when communicating through Proxy_pass and upstream server. This error can occur at some point when DNS resolution fails:
Copy Code code as follows:
Domain.com could not to be resolved.
You can specify multiple DNS and reset the domain name TTL extension nginx resolution cache to ensure resolution success:
Copy Code code as follows:
Resolver 223.5.5.5 223.6.6.6 1.2.4.8 114.114.114.114 valid=3600s;
If there are parsing errors, you can use DNSMASQ to build your own DNS locally, incidentally, with the benefit of accelerated parsing:
Copy Code code as follows:
#/etc/dnsmasq.conf
domain-needed
Bogus-priv
cache-size=51200
listen-address=127.0.0.1
#server =223.5.5.5
Resolv-file=/etc/resolv.conf
Also note that Proxy_pass is not every request will be resolved, if upstream IP frequent changes, you need to force resolution:
Copy Code code as follows:
# via http://forum.nginx.org/read.php?2,215830,215832
Resolver 127.0.0.1;
Set $backend "foo.example.com";
Proxy_pass http://$backend;