0

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?

Patrick Mevzek
  • 9,273
  • 7
  • 29
  • 42
Shinebayar G
  • 275
  • 4
  • 9

1 Answers1

1

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

  1. Putting local ip address in your hosts file
  2. Using split DNS (if you have internal and external dns, it might be something to look at)
  3. Using settings on your router to set routing rules so your router can redirect requests to your internal server.

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.

darthzejdr
  • 138
  • 1
  • 1
  • 6