PHP Firewall

A WordPress plugin by Carles Mateo. Block abusive IPs and URL scanners (.env, wp-config.php, .git and custom patterns). Manual IP/range deny rules, automatic offender collection, CSV & ufw export.

Buy PHP Firewall
PHP Firewall for WordPress logo

Description

PHP Firewall protects your site by blocking abusive visitors as early as possible in the request, before WordPress finishes loading.

When protection is enabled, every request is checked:

  1. If the visitor IP is already a known offender, it gets a 403 Forbidden.
  2. If the IP matches one of your manual deny rules (single IP, CIDR block or hyphen range, IPv4 or IPv6), it gets a 403.
  3. Otherwise the requested URL is inspected. If it matches a scanner signature, the IP is recorded and the request gets a 403.

Built-in scanner signatures: .env, wp-config.php, .git. You can add your own substring patterns too.

Proxy / CDN aware

Choose which header carries the real visitor IP: REMOTE_ADDR, Cloudflare (CF-Connecting-IP), Fastly (Fastly-Client-IP), X-Forwarded-For, X-Real-IP, or a custom header — so the plugin works correctly behind nginx, Varnish, a load balancer or a CDN.

Runs early

When protection is enabled, the plugin installs a tiny must-use loader so the deny check runs on muplugins_loaded. If the mu-plugins directory is not writable, it falls back to plugins_loaded.

Exports

Specifications

PHP WP Firewall

  • Unlimited manual deny rules
  • IPv4 and IPv6 support
  • Unlimited custom URL patterns
  • Unlimited stored automatic offenders
  • Record latest requests
  • Show IPs with most requests in the last 24 hours
  • Block IPs based on number of requests on a given interval
  • Automatic updates
PHP Firewall for WordPress - configuration and protection options

Installation

  1. Upload the php-firewall folder to /wp-content/plugins/, or install the zip via Plugins → Add New → Upload Plugin.
  2. Activate PHP Firewall through the Plugins menu. The database tables are created on activation.
  3. Open PHP Firewall in the admin menu.
  4. Set the Client IP source to match your hosting (behind Cloudflare, Fastly, nginx, etc.).
  5. Click Enable protection.

Frequently Asked Questions

Does it work behind Cloudflare, Fastly or a reverse proxy?

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.

What happens when protection is disabled?

Nothing is blocked and no offenders are collected. Your existing rules are kept.

Where is the data stored?

In three custom tables: cmwpfw_firewall_config, cmwpfw_firewall_manual_ip_deny_rules and cmwpfw_firewall_automatic_ip_deny_rules.

Can I export the blocklist to my server firewall?

Yes. Export the automatic offenders as a ufw script or as CSV from the settings page.

Screenshot

PHP Firewall - automatic offending IP addresses
← Back to carlesmateo.com