Skip to main content

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.

Supported formats: TXT (one IP/CIDR per line)

Steps

  1. 1

    Download the blocklist

    Fetch the TXT blocklist from your AntiProxies dashboard. Caddy's remote_ip matcher accepts IPs and CIDR ranges directly.

  2. 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. 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. 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 Sample

Caddyfile – import blocklist snippet

Use the import directive to load the generated blocklist snippet.

/etc/caddy/Caddyfile
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.

/etc/caddy/blocklists/antiproxies.caddy
@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?
There is no hard limit, but very large lists (100k+ entries) will increase config reload time. For massive lists consider using Caddy's Layer4 app or a WAF.
Does Caddy support CIDR ranges in remote_ip?
Yes. You can mix individual IPs and CIDR blocks (e.g. 10.0.0.0/8) in the same remote_ip matcher.
How do I handle X-Forwarded-For with Caddy?
Add trusted_proxies static <LB_CIDR> inside the servers block of your global options so Caddy uses the real client IP from the forwarded header.

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.

30-day money-back guarantee
All databases included
Monthly updates