I have two php files in a same directory of a server (http://www.xxxx.com/php/),
1) write_json.php
$address['http_client'] = $_SERVER['HTTP_CLIENT_IP']; $address['http_x_forwarded_for'] = $_SERVER['HTTP_X_FORWARDED_FOR']; $address['http_x_forwarded'] = $_SERVER['HTTP_X_FORWARDED']; $address['http_forwarded_for'] = $_SERVER['HTTP_FORWARDED_FOR']; $address['http_forwarded'] = $_SERVER['HTTP_FORWARDED']; $address['remote_addr'] = $_SERVER['REMOTE_ADDR']; header('Content-Type: application/json'); echo json_encode($address); 2) get_ip.php
$json_url = $_SERVER['SERVER_NAME'] . '/php/write_json.php'; $json_string = ''; $ch = curl_init($json_url); $options = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => array('Content-type: application/json'), CURLOPT_POSTFIELDS => $json_string); curl_setopt_array($ch, $options); $json_string = curl_exec($ch); echo $json_string; get_ip.php calls write_json.php
if we suppose the client IP is : 76.2.35.46 and the server one is : 80.59.3.23
when I call http://www.xxxx.com/php/get_ip.php on a client browser
It shows me the Server IP not the client IP like this :
{ http_client: null, http_x_forwarded_for: null, http_x_forwarded: null, http_forwarded_for: null, http_forwarded: null, remote_addr: "80.59.3.23" } How can I get the client IP instead of the server one ?