I have 2 web servers, Server A & Server B. Both running PHP5 + Apache + Ubuntu environment.
Server A sends a request via cURL in PHP to Server B. I would like to get the source server domain of the request. As far as I know, $_SERVER['REMOTE_ADDR']
can get the IP of the source server (Server A). If I want to get the domain of Server A, how can I get it?
p.s. Server A hosts multiple domains, thus reverse IP resolve does not work in this case.
Here are the codes :
$data = array('user' => $user, 'pass' => $pass);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://ServerB/handler.php');
curl_setopt($ch, CURLOPT_PORT, 80);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$ans_xml = curl_exec($ch);