Skip to content

Commit

Permalink
isCloudFlareIP: Compatibility with X_REAL_IP.
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek authored Feb 23, 2022
1 parent 76aa10c commit 1bf51e4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Cloudflare.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public static function isCloudFlare(): bool
public static function isCloudFlareIP(?string $ip = null): bool
{
$ip = $ip ?? ($_SERVER['REMOTE_ADDR'] ?? Ip::LOCALHOST);
if ($ip === Ip::LOCALHOST) { // using proxy
$ip = $_SERVER['HTTP_X_REAL_IP'] ?? $ip;
}
if ($ip === Ip::LOCALHOST) {
return false;
}
Expand Down

0 comments on commit 1bf51e4

Please # to comment.