Laravel package to block direct requests to your Cloudlfare-protected origin server.
emotality/laravel-block-cf-origin is a Laravel package for laravel package to block direct requests to your cloudlfare-protected origin server..
It currently has 0 GitHub stars and 8 downloads on Packagist (latest version 1.0.2).
Install it with composer require emotality/laravel-block-cf-origin.
Discover more Laravel packages by emotality
or browse all Laravel packages to compare alternatives.
Last updated
Laravel package to block direct requests to your Cloudlfare-protected origin server.
This packages should only be used when the following applies:
set_real_ip_from / mod_remoteip module to forward the user's real IP (X-Forwarded-For). If you don't need to forward the user's real IP, rather add deny/allow rules to your Nginx/Apache config.cloudflared and create a tunnel. Read moreSee Useful Links section below for more information.
*Note: This package only supports the Redis cache driver!
composer require emotality/laravel-block-cf-originphp artisan vendor:publish --provider="Emotality\Cloudflare\CloudflareBlockOriginServiceProvider"app/Http/Kernel.php:protected $middleware = [
\Emotality\Cloudflare\BlockNonCloudflareRequests::class, // Top is preferred
...
];
protected function schedule(Schedule $schedule): void
{
...
$schedule->call(new \Emotality\Cloudflare\GetNetmasks)->weekly();
}
config/cloudflare-block.php config and .env accordingly.server {
server_name example.com;
...
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param CF_EDGE_IP $realip_remote_addr; <<----- HERE
include fastcgi_params;
}
}
$realip_remote_addr will be Cloudflare's IP if the request went through a Cloudflare Edge proxy, or the user's IP if the request was direct.
$remote_addr will be the user's IP address.
This package is in its early stages, feel free to report any issues or suggest improvements. Please use the master branch for any pull requests.
laravel-block-cf-origin is released under the MIT license. See LICENSE for details.