Proxy : Récupérer la vériable adresse IP du client depuis le proxy
This commit is contained in:
parent
348eeccdbf
commit
1d9d8703b8
@ -66,6 +66,10 @@ class Scores_Ws_Server
|
||||
'127.0.0.1',
|
||||
'192.168.*',
|
||||
);
|
||||
|
||||
protected $listProxyIp = array(
|
||||
'62.210.222.34',
|
||||
);
|
||||
|
||||
/**
|
||||
* List all permission
|
||||
@ -522,10 +526,19 @@ class Scores_Ws_Server
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo : with proxy get the original IP
|
||||
* With proxy get the original IP
|
||||
* $request->getClientIp(true);
|
||||
* Si IP Proxy regarder la valeur HTTP_X_FORWARDED_FOR
|
||||
*/
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) && in_array($ip, $this->listProxyIp)) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lors d'une demande d'authentification depuis une application on garde l'IP en mémoire,
|
||||
* c'est donc celle là qu'il faut utiliser.
|
||||
*/
|
||||
if ($this->authIp !== null) {
|
||||
$ip = $this->authIp;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user