atk14 / cloudflare-env-adjuster
Adjust the environment of a web app behind Cloudflare protection.
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/atk14/cloudflare-env-adjuster
Requires
- php: >=5.6
- atk14/ip-matcher: >=1.0
Requires (Dev)
- atk14/functions: >=1.0.4
- atk14/http: *
- atk14/tester: *
This package is auto-updated.
Last update: 2025-10-25 10:00:07 UTC
README
Adjust the environment of a web app behind Cloudflare protection.
Basically if CloudflareEnvAdjuster detects that the remote address in the current request is from one of Cloudflare's ranges, it transparently replaces $_SERVER["REMOTE_ADDR"] with $_SERVER["HTTP_X_FORWARDED_FOR"] and stores the original REMOTE_ADDR into $_SERVER["X_CF_REMOTE_ADDR"].
Usage in an ATK14 application
<?php
// file: config/after_initialize.php
CloudflareEnvAdjuster::AdjustEnv();
Usage in a non-ATK14 application
Place the call to CloudflareEnvAdjuster::AdjustEnv() as close to the beginning of your PHP script as you can.
Installation
Just use the Composer:
composer require atk14/cloudflare-env-adjuster
License
CloudflareEnvAdjuster is free software distributed under the terms of the MIT license