{"id":15715731,"url":"https://github.com/monicahq/laravel-cloudflare","last_synced_at":"2025-05-15T19:09:05.387Z","repository":{"id":37677115,"uuid":"151693586","full_name":"monicahq/laravel-cloudflare","owner":"monicahq","description":"Add Cloudflare ip addresses to trusted proxies for Laravel.","archived":false,"fork":false,"pushed_at":"2025-03-04T21:41:03.000Z","size":346,"stargazers_count":299,"open_issues_count":4,"forks_count":33,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-07T02:32:48.528Z","etag":null,"topics":["cloudflare-ips","hacktoberfest","trusted-proxies"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/monicahq.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"asbiin"}},"created_at":"2018-10-05T08:43:26.000Z","updated_at":"2025-04-30T07:46:17.000Z","dependencies_parsed_at":"2023-12-16T17:04:54.602Z","dependency_job_id":"38a158d6-5c2f-4fb7-adb5-447c001927e4","html_url":"https://github.com/monicahq/laravel-cloudflare","commit_stats":{"total_commits":159,"total_committers":12,"mean_commits":13.25,"dds":0.5911949685534591,"last_synced_commit":"033850b4c3e28d017c79eeab5f25d7948c8f7174"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monicahq%2Flaravel-cloudflare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monicahq%2Flaravel-cloudflare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monicahq%2Flaravel-cloudflare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monicahq%2Flaravel-cloudflare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monicahq","download_url":"https://codeload.github.com/monicahq/laravel-cloudflare/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254404357,"owners_count":22065641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare-ips","hacktoberfest","trusted-proxies"],"created_at":"2024-10-03T21:42:35.203Z","updated_at":"2025-05-15T19:09:05.362Z","avatar_url":"https://github.com/monicahq.png","language":"PHP","funding_links":["https://github.com/sponsors/asbiin"],"categories":["PHP"],"sub_categories":[],"readme":"# Trust Cloudflare's Proxies for Laravel\n\nAdd Cloudflare ip addresses to trusted proxies for Laravel.\n\n[![Latest Version](https://img.shields.io/packagist/v/monicahq/laravel-cloudflare?style=flat-square\u0026label=Latest%20Version)](https://github.com/monicahq/laravel-cloudflare/releases)\n[![Downloads](https://img.shields.io/packagist/dt/monicahq/laravel-cloudflare?style=flat-square\u0026label=Downloads)](https://packagist.org/packages/monicahq/laravel-cloudflare)\n[![Workflow Status](https://img.shields.io/github/workflow/status/monicahq/laravel-cloudflare/Unit%20tests?style=flat-square\u0026label=Workflow%20Status)](https://github.com/monicahq/laravel-cloudflare/actions?query=branch%3Amain)\n[![Quality Gate](https://img.shields.io/sonar/quality_gate/monicahq_laravel-cloudflare?server=https%3A%2F%2Fsonarcloud.io\u0026style=flat-square\u0026label=Quality%20Gate)](https://sonarcloud.io/dashboard?id=monicahq_laravel-cloudflare)\n[![Coverage Status](https://img.shields.io/sonar/coverage/monicahq_laravel-cloudflare?server=https%3A%2F%2Fsonarcloud.io\u0026style=flat-square\u0026label=Coverage%20Status)](https://sonarcloud.io/dashboard?id=monicahq_laravel-cloudflare)\n\n\n# Installation\n\n1. Install package using composer:\n```\ncomposer require monicahq/laravel-cloudflare\n```\n\n\n1. Configure Middleware\n\nReplace `TrustProxies` middleware in your `bootstrap/app.php` file:\n\n```php\n-\u003ewithMiddleware(function (Middleware $middleware) {\n    $middleware-\u003ereplace(\n        \\Illuminate\\Http\\Middleware\\TrustProxies::class,\n        \\Monicahq\\Cloudflare\\Http\\Middleware\\TrustProxies::class\n    );\n})\n```\n\n## Custom proxies callback\n\nYou can define your own proxies callback by calling the `LaravelCloudflare::getProxiesUsing()` to change the behavior of the `LaravelCloudflare::getProxies()` method.\nThis method should typically be called in the `boot` method of your `AppServiceProvider` class:\n\n```php\nuse Illuminate\\Support\\ServiceProvider;\nuse Monicahq\\Cloudflare\\LaravelCloudflare;\nuse Monicahq\\Cloudflare\\Facades\\CloudflareProxies;\n\nclass AppServiceProvider extends ServiceProvider\n{\n    /**\n     * Bootstrap any application services.\n     */\n    public function boot(): void\n    {\n        LaravelCloudflare::getProxiesUsing(fn() =\u003e CloudflareProxies::load());\n    }\n}\n```\n\n\n# How it works\n\nThe middleware uses [Illuminate\\Http\\Middleware\\TrustProxies](https://github.com/laravel/framework/blob/8.x/src/Illuminate/Http/Middleware/TrustProxies.php) as a backend.\n\nWhen the cloudflare ips are detected, they are used as trusted proxies.\n\n\n# Refreshing the Cache\n\nThis package retrieves Cloudflare's IP blocks, and stores them in cache.\nWhen request comes, the middleware will get Cloudflare's IP blocks from cache, and load them as trusted proxies.\n\nYou'll need to refresh the cloudflare cache regularely to always have up to date proxy.\n\nUse the `cloudflare:reload` artisan command to refresh the IP blocks:\n\n```sh\nphp artisan cloudflare:reload\n```\n\n## Suggestion: add the reload command in the schedule\n\nAdd a schedule to your `routes/console.php` file to refresh the cache, for instance:\n\n```php\nuse Illuminate\\Support\\Facades\\Schedule;\n\nSchedule::command('cloudflare:reload')-\u003edaily();\n```\n\n# View current Cloudflare's IP blocks\n\nYou can use the `cloudflare:view` artisan command to see the cached IP blocks:\n\n```sh\nphp artisan cloudflare:view\n```\n\n# Option: publish the package config file\n\nIf you want, you can publish the package config file to `config/laravelcloudflare.php`:\n\n```sh\nphp artisan vendor:publish --provider=\"Monicahq\\Cloudflare\\TrustedProxyServiceProvider\"\n```\n\nThis file contains some configurations, but you may not need to change them normally.\n\n## Running tests for your package\n\nWhen running tests for your package, you generally don't need to get Cloudflare's proxy addresses.\nYou can deactivate the Laravel Cloudflare middleware by adding the following environment variable in\nyour `.env` or `phpunit.xml` file:\n\n```\nLARAVEL_CLOUDFLARE_ENABLED=false\n```\n\n\n# Compatibility\n\n| Laravel  | [monicahq/laravel-cloudflare](https://github.com/monicahq/laravel-cloudflare) |\n|----------|----------|\n| 5.x-6.x  | \u003c= 1.8.0 |\n| 7.x-8.53 |  2.0.0   |\n| \u003e= 8.54 | \u003e= 3.0.0 |\n\n\n# Citations\n\nThis package was inspired by [lukasz-adamski/laravel-cloudflare](https://github.com/lukasz-adamski/laravel-cloudflare) and forked from [ogunkarakus/laravel-cloudflare](https://github.com/ogunkarakus/laravel-cloudflare).\n\n\n# License\n\nAuthor: [Alexis Saettler](https://github.com/asbiin)\n\nThis project is part of [MonicaHQ](https://github.com/monicahq/).\n\nCopyright © 2019–2024.\n\nLicensed under the MIT License. [View license](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonicahq%2Flaravel-cloudflare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonicahq%2Flaravel-cloudflare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonicahq%2Flaravel-cloudflare/lists"}