Web Server
Caddy Blocklist Tutorial
Block VPN and proxy IPs in Caddy using remote_ip request matchers loaded from a TXT blocklist file at startup or via the file_server module.
Steps
- 1
Download the blocklist
Fetch the TXT blocklist from your AntiProxies dashboard. Caddy's remote_ip matcher accepts IPs and CIDR ranges directly.
- 2
Build the Caddyfile snippet
Use a script to inline the IPs into a remote_ip matcher or generate a Caddy JSON config fragment.
- 3
Include snippet in Caddyfile
Use the import directive to pull in the generated snippet from a separate file and keep your main Caddyfile clean.
- 4
Reload Caddy
Run caddy reload --config /etc/caddy/Caddyfile to apply the new config without restarting the process.
Need the blocklist files?
Download free sample data or subscribe for daily-updated lists.
Free SampleCaddyfile – import blocklist snippet
Use the import directive to load the generated blocklist snippet.
example.com {
# Import the AntiProxies blocklist snippet
import /etc/caddy/blocklists/antiproxies.caddy
reverse_proxy localhost:3000
} Generated blocklist snippet
Blocklist snippet – list all IPs space-separated after remote_ip. Reload Caddy after editing.
@blocked_ips remote_ip 1.2.3.4 5.6.7.0/24 10.0.0.1 192.168.100.0/22
respond @blocked_ips "Access denied" 403 Frequently asked questions
Is there a limit to how many IPs remote_ip can handle?
Does Caddy support CIDR ranges in remote_ip?
How do I handle X-Forwarded-For with Caddy?
Want to see what's in the database?
Download once, query as many times as you need. €99/year for all 22 databases, unlimited servers, and a full year of monthly updates. No usage limits, no per-query fees, no data leaving your servers.