A Drupal module by Carles Mateo. Block abusive IPs and URL scanners
(.env,
settings.php,
.git and custom patterns).
Manual IP/range deny rules, automatic offender collection, CSV & ufw export.
Description
PHP Drupal Firewall protects your site by blocking abusive visitors as early as possible in the request, before Drupal finishes loading.
When protection is enabled, every request is checked:
Built-in scanner signatures: .env, settings.php, .git.
You can add your own substring patterns too.
Choose which header carries the real visitor IP: REMOTE_ADDR,
Cloudflare (CF-Connecting-IP), X-Forwarded-For,
X-Real-IP, or a custom header — so the module works correctly behind nginx,
Varnish, a load balancer or a CDN.
When protection is enabled, the deny check runs at an early stage of Drupal's bootstrap, before the full site is loaded, so bad requests are rejected while consuming as little CPU and resources as possible.
ufw insert 1 deny from 185.225.69.214 to any.Specifications
Frequently Asked Questions
Yes. In the settings, choose the header that carries the real client IP for your setup. Only trust a forwarded header if your server genuinely sits behind that proxy, otherwise the value can be spoofed.
Nothing is blocked and no offenders are collected. Your existing rules are kept.
In three custom database tables created by the module: one for configuration, one for the manual deny rules and one for the automatic offenders.
Yes. Export the automatic offenders as a ufw script or as CSV from the settings page.
It is very fast and really useful. Every site should have a plugin like this.
Screenshot