proxy_pass does not resolve DNS using /etc/hosts

血红的双手。 提交于 2021-01-20 17:59:45

问题


In nginx the proxy_pass directive is not resolving DNS using the /etc/hosts file. Any way to enable this possibility (maybe by leveraging Lua as a last resort)?


回答1:


In short, you need to install dnsmasq locally and use 127.0.0.1 as a resolver.

See this related question and answer:

When using proxy_pass, can /etc/hosts be used to resolve domain names instead of "resolver"?




回答2:


If you have a server with systemd you can use the nameserver shipped with it, systemd-resolved, to resolve your hostnames from the /etc/hosts file.

Just add this to your nginx config http, server or location block:

resolver 127.0.0.53;

Use systemctl status systemd-resolved.service to see if it running on your server.



来源:https://stackoverflow.com/questions/29980884/proxy-pass-does-not-resolve-dns-using-etc-hosts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!