0

This question already has an answer here:

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?

marked as duplicate by HBruijn, Gerald Schneider, Patrick Mevzek, Community Aug 17 at 2:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Thank you @HBruijn , looks like this is the answer. Also thanks for the grammar edit guys! – Shinebayar G Aug 17 at 2:51
0

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.

  • Thanks for the answer. Looks like this is the direct answer to the question. – Shinebayar G Aug 17 at 2:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.