⚠️ Status: untested. This extension is provided as-is and has not been tested in production. Please feel free to fork, modify, improve, and open pull requests.Licensed under GNU GPLv3 (see LICENSE).
A DirectAdmin plugin that screens every visitor to all hosted sites against the IP-Block.com API and blocks bad IPs before your customers' PHP applications run. Configured from an Admin Level settings page.
- Panel: DirectAdmin
- Version targeted: 1.705 (current channel, 2026); works on 1.6xx/1.7xx with CustomBuild PHP-FPM.
- Plugin type: Admin-level plugin page (PHP CGI) + drop-in PHP enforcement
guard (
auto_prepend_file).
POST https://api.ip-block.com/v1/check
Content-Type: application/json
{"api_key","site_id","ip","user_agent","referrer"} -> {"action":"allow|block"}
A visitor is blocked only when action === "block". Hard 1 second
timeout; fails open (visitor allowed) on any error/timeout/non-2xx/missing
action by default. Per-IP decisions are cached (APCu or temp file) for
cache_ttl seconds. CLI and cron are never screened.
ipblock/
├── plugin.conf # DirectAdmin plugin manifest
├── ipblock-guard.php # Shared enforcement guard
├── admin/index.html # Admin settings page (PHP CGI; note shebang)
├── scripts/install.sh # Install hook (run as root by DA)
├── scripts/uninstall.sh # Uninstall hook
└── config.json # Created on install (protection disabled)
At runtime:
| Path | Purpose |
|---|---|
/opt/ipblock/ipblock-guard.php | Installed guard (auto_prepend target) |
/usr/local/directadmin/plugins/ipblock/config.json | Config the guard reads |
/usr/local/php*/lib/php.conf.d/zzz-ipblock.ini | Registers auto_prepend per PHP version |
DirectAdmin expects a tarball whose top-level directory is the plugin id:
tar czf ipblock.tar.gz ipblock/DirectAdmin UI: Admin Level > Plugin Manager > Add Plugin > upload
ipblock.tar.gz. DirectAdmin extracts it to
/usr/local/directadmin/plugins/ipblock/ and runs scripts/install.sh as root.
CLI (manual):
tar xzf ipblock.tar.gz -C /usr/local/directadmin/plugins/
bash /usr/local/directadmin/plugins/ipblock/scripts/install.shThe install hook installs the guard, creates a default config (protection
disabled), writes auto_prepend_file INI drop-ins for every CustomBuild PHP
version, and restarts PHP-FPM.
Then open Admin Level > IP-Block Protection, enter your Site ID and API Key, tick Enable protection, and Save.
| Setting | Default | Notes |
|---|---|---|
| Enable protection | off | Master switch |
| Site ID / API Key | — | From your ip-block.com account |
| API URL | https://api.ip-block.com/v1/check | |
| Fail open | on | Allow visitors when API unreachable (recommended) |
| Cache TTL | 300 | Seconds to cache per-IP decision |
| Behind proxy / Real-IP header | off / X-Forwarded-For | Trust proxy/CDN header for client IP |
| Block action | 403 | 403 page or redirect |
| Block message / Redirect URL | Access denied. / blocked.php | |
| Whitelist | empty | One IP or CIDR per line; never checked |
Remove via Plugin Manager (runs scripts/uninstall.sh), or manually:
bash /usr/local/directadmin/plugins/ipblock/scripts/uninstall.sh
rm -rf /usr/local/directadmin/plugins/ipblock- The admin page is only reachable by authenticated DirectAdmin admins
(
admin_only=yes) and carries a per-install CSRF token. - The guard is dependency-free, safe to load twice, and wrapped in a catch-all so it can never take a customer site down.