proxy_pass does not resolve DNS using /etc/hosts

后端 未结 2 1508
一生所求
一生所求 2021-02-05 12:15

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

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 13:09

    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.

提交回复
热议问题