使用proxy_pass时,可以使用/etc/hosts代替"resolver"来解析域名吗? [英] When using proxy_pass, can /etc/hosts be used to resolve domain names instead of "resolver"?

查看:375
本文介绍了使用proxy_pass时,可以使用/etc/hosts代替"resolver"来解析域名吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 proxy_pass 时可以使用/etc/hosts 代替 resolver 吗?

Can /etc/hosts be used instead of resolver when using proxy_pass?

我需要对同一台nginx机器执行proxy_pass.有没有一种方法可以使用计算机的/etc/hosts文件来解析域,而不是通过"resolver"属性来指定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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆