I've an Nginx web server running on 192.168.10.1
address. Also, I've pointed my domain to this server. This server has public IP NAT-d through the corporate network. I can access my website fine from an outside network using the domain name. However, I cannot access this website from the server itself or over LAN network (from 192.168.10.2
server)
For example, curl mydomain.example
doesn't respond from the server itself or from secondary server 192.168.10.2
I can actually put this server's internal IP address inside both server's /etc/hosts
and curl works fine. But I want to solve root cause if possible, anyone faced similar situations? What could be causing this issue?
The problem is you are trying to access resource from inside lan by using a public address. Most routers get confused with that.
There are several solutions (that i used, there might be more):
Which one you use will mostly depend on your network setup and available hardware. Hosts file is the simplest, but if it's a laptop you use outside the network as well, you'll have to enable/disable the rule depending on where you are. Second option is only good if you already have an internal/external dns setup, and third will depend on your router capabilities. It's the one i use atm(My router is a Mikrotik). There are probably more solutions out there, so you can look to other responses or google.