Skip to main content

Reverse Proxy

Traefik Blocklist Tutorial

Use Traefik's IPAllowList middleware with a CSV/TXT deny list to block proxy and VPN IP addresses at the reverse proxy layer in Docker or Kubernetes environments.

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

Steps

  1. 1

    Download the blocklist

    Fetch the TXT blocklist from your AntiProxies dashboard. You'll convert this to a YAML list for Traefik's dynamic configuration.

  2. 2

    Generate dynamic config

    Write a script that converts the TXT list into a Traefik dynamic configuration YAML file defining an IPAllowList middleware in deny mode.

  3. 3

    Point Traefik to the config file

    Configure Traefik's file provider to watch the directory containing your dynamic config so changes are picked up automatically.

  4. 4

    Attach middleware to routers

    Add the blocklist middleware to your Traefik router using labels (Docker) or IngressRoute annotations (Kubernetes).

Need the blocklist files?

The annual license includes every format and monthly data releases.

Get the complete lists Inspect sample data

Dynamic config – IPDenyList middleware

Generated Traefik dynamic config defining a deny-list middleware.

/etc/traefik/dynamic/antiproxies.yml
http:
  middlewares:
    antiproxies-block:
      ipAllowList:
        # Empty allow-list = allow all; we invert with a deny approach.
        # Traefik 3.x supports ipDenyList natively:
        ipDenyList:
          sourceRange:
            - "1.2.3.4/32"
            - "5.6.7.0/24"
            - "10.0.0.1/32"
            - "192.168.100.0/22"

traefik.yml – enable file provider

Enable the file provider so Traefik watches the dynamic config directory.

/etc/traefik/traefik.yml
providers:
  file:
    directory: /etc/traefik/dynamic
    watch: true   # Hot-reload on file change

entryPoints:
  web:
    address: ":80"
  websecure:
    address: ":443"

Docker Compose – attach middleware

Apply the antiproxies-block middleware to a service via labels.

docker-compose.yml
services:
  app:
    image: my-app:latest
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.app.rule=Host(`example.com`)"
      - "traefik.http.routers.app.middlewares=antiproxies-block@file"

Frequently asked questions

Does Traefik need a restart to pick up the new YAML file?
No. The file provider with watch: true detects changes and reloads dynamic configuration automatically, with zero downtime.
What is the difference between ipAllowList and ipDenyList?
ipAllowList specifies IPs that are allowed (block everyone else). ipDenyList (Traefik 3.x) specifies IPs that are blocked. For a blocklist use ipDenyList. On Traefik 2.x you can invert an allowList using the NotIp plugin.
How do I get the real client IP in Docker / Kubernetes?
Configure the forwardedHeaders section in Traefik to trust your ingress/LB IP and set X-Real-IP or X-Forwarded-For so the middleware sees the real client address.

Put the full dataset in your stack

€99/year gets you all 22 data categories, unlimited local queries, and one year of updates. Load the files once, keep your decision logic in-house, and update on your own deployment schedule.

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