使用proxy_pass时,可以用/etc/hosts代替“resolver"来解析域名吗? [英] When using proxy_pass, can /etc/hosts be used to resolve domain names instead of "resolver"?
问题描述
在使用proxy_pass时,可以使用/etc/hosts代替解析器吗?
Can /etc/hosts be used instead of resolver when using proxy_pass?
我需要对同一台 nginx 机器执行 proxy_pass.有没有办法使用机器的/etc/hosts 文件来解析域,而不是通过解析器"属性指定 DNS 服务器?
I need to perform a proxy_pass to the same nginx machine. Is there a way to resolve the domains using the machine's /etc/hosts file instead of specifying a DNS server thru the "resolver" property?
这将为我节省到达同一服务器所需的额外跃点.我尝试在/etc/hosts 文件中设置映射到 DNS 的内部 IP,但 nginx 仍在从 resolver 属性中设置的 DNS 服务器读取.或者有没有办法让HTTPProxy模块考虑/etc/hosts文件设置?
This will save me the additional hops needed to reach the same server. I have tried setting up the internal IP mapped to the DNS in /etc/hosts file but nginx is still reading from the DNS server set in the resolver property. Or is there a way to make the HTTPProxy module to consider the /etc/hosts file settings?
感谢您可以分享的任何建议..
Thanks for any advice you could share..
这与我在 nginx 论坛中发布的问题相同:http://forum.nginx.org/read.php?11,218997
This is the same question I posted in the nginx forum: http://forum.nginx.org/read.php?11,218997
推荐答案
您可以通过安装 dnsmasq
并将解析器设置为 127.0.0.1
来解决此问题.基本上这使用您的本地 DNS 作为解析器,但它只解析它知道的内容(其中包括您的 /etc/hosts
)并将其余部分转发到您的默认 DNS.
You can get around this by installing dnsmasq
and setting your resolver to 127.0.0.1
. Basically this uses your local DNS as a resolver, but it only resolves what it knows about (among those things is your /etc/hosts
) and forwards the rest to your default DNS.
这篇关于使用proxy_pass时,可以用/etc/hosts代替“resolver"来解析域名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!