proxy_pass does not resolve DNS using /etc/hosts
Asked Answered
A

2

20

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

Arawn answered 1/5, 2015 at 2:38 Comment(0)
S
9

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 is running on your server.

Sophistication answered 19/11, 2020 at 9:54 Comment(0)
A
5

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

Andrey answered 28/8, 2015 at 9:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.