Add Cloudflare ip addresses to trusted proxies for Laravel.
Clone or download

README.md

Trust Cloudflare's Proxies for Laravel

Add Cloudflare ip addresses to trusted proxies for Laravel.

Latest Version

Installation

Install using composer:

composer require monicahq/laravel-cloudflare

You don't need to add this package to your service providers.

Add the middleware in app/Http/Kernel.php, adding a new line in the middleware array:

\Monicahq\Cloudflare\Http\Middleware\TrustProxies::class

Support

This package supports Laravel 5.6 or newer.

Refreshing the Cache

This package basically retrieves Cloudflare's IP blocks, and stores in cache.

When request comes, loads Cloudflare's IP blocks to trusted proxies.

That's why, you'll need to every day refresh the cache.

You can use the following command for this.

php artisan cloudflare:reload

Suggestion: add the command in the schedule.

Add a new line in app/Console/Kernel.php, in the schedule function:

$schedule->command('cloudflare:reload')->daily();

View current Cloudflare's IP blocks

You can use the following command to see the cached IP blocks.

php artisan cloudflare:view

License

This repository licensed under the MIT license.

Citations

This package was inspired by lukasz-adamski/laravel-cloudflare and forked from ogunkarakus/laravel-cloudflare.