I've got two Linux servers set up at the same datacenter. They're hooked up through a private switch, and they respond to each other on local IP addresses (192.168.0.N
and 192.168.0.M
).
Currently, I have a PHP file on Server N calling a PHP file on Server M via (basically) file_get_contents("http://$domain/$folder/$filename.php");
, and that file runs a PHP script on the destination server. The problem with this, of course, is that it goes out over the internet, chewing up bandwidth in both the send and the reply. This is why I hooked them up with the private switch.
How can I set it up so that I can call the other file by replacing the $domain
with the 192.168.0.M
address? What settings do I have to change on Server N (Centos 6.6, running WHM and CPanel) in order for it to recognize that 192.168.0.M
will shortcut to $domain
's home folder on Server M?
This is commonly handled with split horizon DNS, where internal DNS queries get answered differently than external ones.
It's best to do this via a proper internal DNS server, but if you can't, you can adjust the hosts file on your servers (in Linux, /etc/hosts
) to override the IP for the domain name.