proxy_pass无法使用/ etc/hosts解析DNS
问题描述:
在nginx中,proxy_pass
指令未使用/etc/hosts
文件解析DNS。任何方式来启用这种可能性(也许通过利用Lua作为最后的手段)?proxy_pass无法使用/ etc/hosts解析DNS
答
Nginx在启动时查找一次IP,如果静态设置,则不再检查。为了得到这个你周围可以尝试将它设置为一个变量:
resolver 127.0.0.1;
set $url "domain.com";
proxy_pass http://$url;
答
总之,你需要在本地安装的dnsmasq和使用127.0.0.1作为一个解析器。
见此相关的问题和答案:
When using proxy_pass, can /etc/hosts be used to resolve domain names instead of "resolver"?