proxy_pass does not resolve DNS using /etc/hosts proxy_pass does not resolve DNS using /etc/hosts nginx nginx

proxy_pass does not resolve DNS using /etc/hosts


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"?


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.