public function getClientIp()
{
$remoteAddress = $this->server()->remoteAddress();
$fwdClientIp = $this->server()->get($this->getTrustedHeaders()['client_ip']);
if ($fwdClientIp && $remoteAddress && in_array($remoteAddress, $this->getTrustedProxies())) {
// Use the forwarded IP address, typically set when the
// client is using a proxy server.
// Format: "X-Forwarded-For: client1, proxy1, proxy2"
$clientIps = explode(',', $fwdClientIp);
$clientIp = array_shift($clientIps);
} elseif ($this->server()->httpClientIp() && $remoteAddress && in_array($remoteAddress, $this->getTrustedProxies())) {
// Use the forwarded IP address, typically set when the
// client is using a proxy server.
$clientIps = explode(',', $this->server()->httpClientIp());
$clientIp = array_shift($clientIps);
} elseif ($this->server()->remoteAddress()) {
// The remote IP address
$clientIp = $this->server()->remoteAddress();
} else {
return false;
}
return $clientIp;
}