Nginx DNS Resolver Configuration Instance _nginx

Source: Internet
Author: User

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.