Proxy_pass does not resolve DNS using / etc / hosts

In nginx, the proxy_pass directive proxy_pass not resolve DNS using the /etc/hosts . Any way to enable this feature (possibly using Lua as a last resort)?

+7
lua nginx dns hosts hosts-file
source share
2 answers

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

See this related question and answer:

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

+4
source share

Nginx looks at the IP once at startup and does not check again if it is statically installed. To get around this, you can try setting it as a variable:

 resolver 127.0.0.1; set $url "domain.com"; proxy_pass http://$url; 
+2
source share

All Articles