Skip to content

Commit

Permalink
Merge pull request #5 from lohanidamodar/fix-multiple-ips-on-proxy
Browse files Browse the repository at this point in the history
fix for multiple ips when routed through proxy
  • Loading branch information
eldadfux authored Feb 10, 2021
2 parents 3ddb132 + 0d54c47 commit 9af223a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ public function getServer(string $key, $default = null)
*/
public function getIP(): string
{
return $this->getServer('HTTP_X_FORWARDED_FOR', $this->getServer('REMOTE_ADDR', '0.0.0.0'));
$ips = explode(',',$this->getHeader('HTTP_X_FORWARDED_FOR', $this->getServer('REMOTE_ADDR', '0.0.0.0')));
return trim($ips[0] ?? '');
}

/**
Expand Down

0 comments on commit 9af223a

Please sign in to comment.