Skip to content

About

IP Block protection for DirectAdmin — ip-block.com integration. Untested at the moment; please feel free to modify. GPLv3.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ 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).

IP-Block.com for DirectAdmin

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).

What it does

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.

Package layout (ipblock/)

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

Build the package

DirectAdmin expects a tarball whose top-level directory is the plugin id:

tar czf ipblock.tar.gz ipblock/

Install

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.sh

The 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.

Configuration (settings page)

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

Uninstall

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

Notes

  • 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.

About

IP Block protection for DirectAdmin — ip-block.com integration. Untested at the moment; please feel free to modify. GPLv3.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages