The Home for Magento 2 Excellence

Quality-tested Magento 2 modules. Explore. Evaluate. Elevate. #magento2

721 Modules
481 Ready
235 Need Help
🏆 Leaderboard
Potentially Abandoned vv1.0.3

Cloudflare Integration

m2-oh/module-cloudflare

Automatically purges Cloudflare cache when Magento cache is flushed and resolves real visitor IPs by reading the CF-Connecting-IP header. Supports per-zone configuration with encrypted API key storage.

298
Downloads
Below average
0
GitHub Stars
3y ago
Last Release
0
Open Issues
Build Issues
0/3 checks passed

Build Tests

Composer Install
DI Compile
Templates

Code Quality

CS Coding Standard
PHPStan

Tested on Magento 2.4.8-p4

Recent Test History

Each release is tested against the latest Magento version at that time.

vv1.0.3 on Magento 2.4.8-p4
Mar 21, 2026

Looking for Contributors

Composer installation fails. Your contribution could help the entire Magento community!

Contribute

Share This Module's Status

Cloudflare Integration Magento compatibility status badge

README

Loaded from GitHub

Magento 2 Cloudflare Integration

A lightweight Magento 2 module that:

  1. Purges Cloudflare cache automatically whenever Magento's cache is flushed (admin panel or CLI).
  2. Resolves real visitor IPs by reading the CF-Connecting-IP header that Cloudflare injects, so Magento logs, rate-limiters, and geo-IP lookups see the actual client address instead of a Cloudflare proxy IP.

Requirements

Dependency Version
PHP ≥ 8.1
Magento 2.4.x
m2-oh/module-core *

Installation

composer require m2-oh/module-cloudflare
bin/magento module:enable OH_Cloudflare
bin/magento setup:upgrade
bin/magento cache:flush

Configuration

Navigate to Stores → Configuration → OH Core → Cloudflare.

Field Description
Enable Cache Purge Master switch. When disabled, no API calls are made.
Account Email The email address associated with your Cloudflare account.
Global API Key Your Cloudflare Global API Key. Stored encrypted.
Zones to Purge Multi-select of zones fetched live from the Cloudflare API.

Tip: Save your email and API key first, then reload the page — the Zones field will populate automatically.


How It Works

Cache Purge

The module listens to three Magento cache events:

Event Trigger
adminhtml_cache_flush_system Admin → Cache Management → Flush Magento Cache
adminhtml_cache_flush_all Admin → Cache Management → Flush Cache Storage
clean_media_cache_after Admin → Flush Media Storage

When any of these events fires and the module is fully configured, Client::purgeAll() calls cachePurgeEverything for each configured zone via API. A success or per-zone failure message is displayed in the admin.

Real IP Resolution

A plugin on Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::getRemoteAddress() replaces the result with $_SERVER['HTTP_CF_CONNECTING_IP'] when present. This is a standard Cloudflare header that is always set when traffic passes through their proxy.

This content is fetched directly from the module's GitHub repository. We are not the authors of this content and take no responsibility for its accuracy, completeness, or any consequences arising from its use.