PHPackages                             rolandverner/symfony-cloudflare - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. rolandverner/symfony-cloudflare

ActiveSymfony-bundle[Security](/categories/security)

rolandverner/symfony-cloudflare
===============================

Symfony bundle for Cloudflare integration: trusted proxies, real client IP detection, forwarded headers.

v1.0.2(3mo ago)11.5k↑88.9%MITPHPPHP &gt;=8.1CI passing

Since Dec 31Pushed 3mo agoCompare

[ Source](https://github.com/rolandverner/symfony-cloudflare)[ Packagist](https://packagist.org/packages/rolandverner/symfony-cloudflare)[ RSS](/packages/rolandverner-symfony-cloudflare/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (9)Versions (4)Used By (0)

[![PHP](https://camo.githubusercontent.com/3e41095f4ad1c6ad78f988bd1c107f87972f334143c3ba814165a03e1f43a63c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/3e41095f4ad1c6ad78f988bd1c107f87972f334143c3ba814165a03e1f43a63c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![Symfony](https://camo.githubusercontent.com/1c8a879de273f0a0568b2dae00e350b77fca88cbf481a55b5d1f0511b140caf8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d3625323025374325323037253230253743253230382d626c61636b3f6c6f676f3d73796d666f6e79)](https://camo.githubusercontent.com/1c8a879de273f0a0568b2dae00e350b77fca88cbf481a55b5d1f0511b140caf8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d3625323025374325323037253230253743253230382d626c61636b3f6c6f676f3d73796d666f6e79)[![Cloudflare](https://camo.githubusercontent.com/73b6825744cbcb9c24771179c91a0173f90c99a1c0bbb7512bb6f8788dbb267d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436c6f7564666c6172652d5472757374656425323050726f786965732d4633383032303f6c6f676f3d636c6f7564666c617265266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/73b6825744cbcb9c24771179c91a0173f90c99a1c0bbb7512bb6f8788dbb267d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436c6f7564666c6172652d5472757374656425323050726f786965732d4633383032303f6c6f676f3d636c6f7564666c617265266c6f676f436f6c6f723d7768697465)[![Latest Version on Packagist](https://camo.githubusercontent.com/ec270bab276a5906960ac33419880b44f37df6e6123244502f1b98312561cc4c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f6c616e647665726e65722f73796d666f6e792d636c6f7564666c6172652e737667)](https://packagist.org/packages/rolandverner/symfony-cloudflare)[![Total Downloads](https://camo.githubusercontent.com/c3b071dc44be4cd722f0cb2a6bd40ec051f52b1d32ed4276845b2d22f009db4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f6c616e647665726e65722f73796d666f6e792d636c6f7564666c6172652e737667)](https://packagist.org/packages/rolandverner/symfony-cloudflare)[![License](https://camo.githubusercontent.com/6ee6098eade0c3b3a0346beb515a956991d46541401470e60e63225dbe61dc31/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f726f6c616e647665726e65722f73796d666f6e792d636c6f7564666c6172652e737667)](LICENSE)

Cloudflare Trusted Proxies Bundle for Symfony (Real IP &amp; Reverse Proxy Support)
===================================================================================

[](#cloudflare-trusted-proxies-bundle-for-symfony-real-ip--reverse-proxy-support)

A production-ready Symfony bundle for integrating Cloudflare with Symfony applications. It ensures correct real client IP detection, trusted proxy configuration, and forwarded headers handling when Symfony runs behind Cloudflare.

Why use Cloudflare with Symfony?
--------------------------------

[](#why-use-cloudflare-with-symfony)

When running Symfony behind Cloudflare, incorrect proxy configuration often causes:

- Wrong client IP addresses (`Request::getClientIp()`)
- Broken HTTPS / scheme detection
- Invalid security and rate-limiting behavior

This bundle automatically configures Symfony trusted proxies using official Cloudflare IPv4 and IPv6 ranges and keeps them up to date.

Features
--------

[](#features)

- **Automatic IP Updates**: Automatically fetches and updates official Cloudflare IPv4 and IPv6 ranges for Symfony trusted proxies.
- **Caching**: IP ranges are cached using Symfony Cache to avoid overhead on every request.
- **Zero Configuration**: Works out of the box with standard Symfony environment variables (`TRUSTED_PROXIES`).
- **Flexible**: Customizable headers, caching, and merging logic.
- **Feature Toggle**: Easily enable or disable the bundle via config or environment variables.

Installation
------------

[](#installation)

```
composer require rolandverner/symfony-cloudflare
```

After installation, register the bundle in your `config/bundles.php`:

```
return [
    // ...
    Cloudflare\Proxy\CloudflareProxyBundle::class => ['all' => true],
];
```

After installation, you can automatically publish the configuration file to your project:

```
php bin/console cloudflare:install
```

Compatibility
-------------

[](#compatibility)

- PHP 8.1+
- Symfony 6.x
- Symfony 7.x
- Symfony 8.x
- Cloudflare (Free, Pro, Business, Enterprise)

Configuration
-------------

[](#configuration)

```
cloudflare_proxy:
    # Whether to enable the Cloudflare trusted proxies listener
    enabled: true

    # Mode: 'append' (default) or 'override'
    # 'append' adds Cloudflare IPs to your existing TRUSTED_PROXIES
    # 'override' replaces them entirely
    mode: append

    # Optional: custom environment variable for trusted proxies
    proxy_env: CLOUDFLARE_TRUSTED_PROXIES

    # Additional proxies to trust (e.g., your local load balancer)
    extra: []
    # Example:
    # extra:
    #     - 10.0.0.1
    #     - 172.16.0.0/12

    # Trusted headers configuration
    trusted_headers:
        - x-forwarded-for
        - x-forwarded-host
        - x-forwarded-proto
        - x-forwarded-port
        - forwarded

    # Cache configuration
    cache:
        pool: cache.app
        key: cloudflare_proxy.ips
        ttl: 86400 # 24 hours
```

Environment Variables
---------------------

[](#environment-variables)

By default, the bundle will automatically merge Cloudflare IPs with any proxies defined in your standard Symfony environment variable:

```
# .env
TRUSTED_PROXIES=127.0.0.1,10.0.0.1

# Optional: Disable the bundle features
CLOUDFLARE_PROXY_ENABLED=false
```

If you prefer to use a custom variable name, you can change `proxy_env` in the configuration.

Usage
-----

[](#usage)

The bundle hooks into the `kernel.request` event with high priority (2000), so it runs before the Security component.

### Commands

[](#commands)

You can manually reload or view the cached IP ranges:

```
# Install the default configuration file
php bin/console cloudflare:install

# Force reload Cloudflare IPs into cache
php bin/console cloudflare:reload

# View currently cached IP ranges
php bin/console cloudflare:view
```

Tip

While the bundle refreshes the cache automatically on request, it is recommended to set up a cron job to keep the cache warm:

```
0 */12 * * * php /path/to/your/project/bin/console cloudflare:reload > /dev/null 2>&1
```

Credits
-------

[](#credits)

This bundle is inspired by [monicahq/laravel-cloudflare](https://github.com/monicahq/laravel-cloudflare).

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance82

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~20 days

Total

3

Last Release

91d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12708415?v=4)[MASQ](/maintainers/rolandverner)[@rolandverner](https://github.com/rolandverner)

---

Top Contributors

[![rolandverner](https://avatars.githubusercontent.com/u/12708415?v=4)](https://github.com/rolandverner "rolandverner (22 commits)")

---

Tags

cloudflarehttpphpreal-ipreverse-proxysecuritysymfonysymfony-bundletrusted-proxiessymfonysecuritycloudflareSymfony Bundletrusted proxiesreverse proxyreal ipforwarded-headers

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rolandverner-symfony-cloudflare/health.svg)

```
[![Health](https://phpackages.com/badges/rolandverner-symfony-cloudflare/health.svg)](https://phpackages.com/packages/rolandverner-symfony-cloudflare)
```

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M193](/packages/simplesamlphp-simplesamlphp)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
