atk14 / cloudflare-env-adjuster
Adjust the environment of a web app behind Cloudflare protection.
v0.1.2
2026-01-26 12:11 UTC
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: 2026-02-26 12:30:09 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