Trouble resolving local hostname when using NGINX as reverse proxy

Hi
I am having trouble resolving hostname when using NGINX as reverse proxy.

I have installed pi-hole in 192.168.3.6

Added local hostname in /etc/hosts of 192.168.3.6

$ cat /etc/hosts
127.0.1.1 raspberrypi
192.168.3.6 webmin.domain.com
192.168.3.10 mail.domain.com
192.168.3.10 nas.domain.com

where 192.168.3.6 and 127.0.0.1 are same

I have added the following in /etc/pihole/lan.list
192.168.3.10 mail.domain.com
192.168.3.10 nas.domain.com

Restarted both dnsmasq and pihole

Dig returns correct IP for the above

$ dig mail.domain.com

;; ANSWER SECTION:
mail.domain.com. 2 IN A 192.168.3.10

But i cannot access mail.domain.com in the browser while can access webmin.domain.com,

I am using googles DNS and my router as DHCP server in pihole's dashboard.

If i change the DNS server to automatic replacing my Pi-holes IP in network properities, everything works.

Nginx has nothing to do with resolving DNS. Does 192.168.3.10 point to a device with a webserver? What is the result of this when using the automatic DNS?

dig mail.domain.com

Right, NGINX has nothing to do with resolving.

Dig results for automatic DNS resolves to external IP.

$ dig mail.domain.com
..............
..............
;; ANSWER SECTION:
mail.domain.com. 59 IN A 100.12.35.141

..............
..............

In the network there is a web server that is not directly connected to mail.domain.com but can ping. to it.

It sounds like it's doing exactly what you told it to do :wink:. Do you want mail.domain.com to go to 192.168.3.10 or 100.12.35.141? You should make sure that there's a webserver listening on 192.168.3.10.

Encouraging to know that. one point i missed-> I m trying out resolving mail.domain.com within the network(192.168.3) and its here that the browser could not resolves it although digging resolves to correct address. When i access mail.domain.com outside the network, i don't have any issues. The address resolves to correct IP.

You should make sure that there’s a webserver listening on 192.168.3.10
So i need to have apache or nginx running in 192.168.3.10 ?

Yes, you need to have it listen to the local address as well if you want to reach it from the local address.