The day you publish a service on the internet, the knocking starts. Within an hour of opening ports 80 and 443, your reverse proxy logs fill with scanning bots, credential-stuffing waves, and exploit probes for CVEs you have never heard of. A firewall blocks ports you did not open; it does nothing about the malicious traffic arriving through the ports you deliberately left open. That gap is exactly what CrowdSec fills.

CrowdSec is an open-source, crowdsourced intrusion prevention system. It reads your service logs, detects known-bad behavior patterns, and blocks the offending IPs — while sharing anonymized attack signals with a global community so your box learns from attacks seen on thousands of other boxes. This guide deploys the current release, v1.8.2 (published 26 October 2026 on the CrowdSec GitHub releases page), alongside Caddy in Docker Compose, wires up blocking, and shows you how to verify the whole loop works.

If you have not set up a reverse proxy yet, read our Caddy reverse proxy guide first — this article assumes Caddy is already terminating your HTTPS traffic. And if you are building out your defenses from scratch, our homelab security essentials covers the full layered approach this guide slots into.

How CrowdSec Works: Engine, Bouncers, and the Crowd

Three concepts carry the whole architecture:

  • The Security Engine is the detection brain. It tails your log files, runs them through parsers and scenarios (collections), and raises alerts when patterns match — SSH brute force, HTTP path traversal, CVE exploit probes, and hundreds more shipped in the CrowdSec Hub collections.
  • Remediation Components (bouncers) do the blocking. The engine detects; it never blocks by itself. A bouncer queries the engine’s local API and enforces decisions: the nginx/OpenResty/Traefik/Caddy bouncers drop or challenge bad HTTP clients, the firewall bouncer drops IPs at the kernel level for SSH, SMTP, and other non-web services. The official bouncer selection guide maps every deployment shape to the right bouncer.
  • The crowd is the multiplier. Your engine optionally shares anonymized attack signals with the CrowdSec network and, in return, receives the community blocklist — IPs currently attacking other participants. One person’s 3 a.m. SSH brute-force wave becomes everyone’s pre-emptive block.

The CrowdSec Console (app.crowdsec.net) gives you a web dashboard for alerts, decisions, and stack health across all your engines, plus free third-party blocklists. Enrollment is optional but recommended.

Prerequisites

You need Docker and Docker Compose (see our Docker basics for homelab guide if this is new), plus a reverse proxy whose logs CrowdSec can read. This guide uses Caddy, matching our Caddy HTTPS guide, and it also works as the authentication front door if you run Authentik SSO in front of your apps.

Plan for two containers: crowdsec (the engine) and a rebuilt caddy image that includes the caddy-crowdsec-bouncer module compiled in via xcaddy. The official example-docker-compose repository documents this exact topology, and the Compose file below follows it.

Since CrowdSec 1.7.0, persisting /var/lib/crowdsec/data/ in a volume is mandatory — the container refuses to start without it. The example below gets this right.

The Docker Compose Stack

Create a project directory and three files: docker-compose.yml, Caddyfile, and crowdsec/acquis.yaml.

services:
  caddy:
    build:
      context: .
      target: caddy
    ports:
      - "80:80"
      - "443:443"
    environment:
      - CROWDSEC_API_KEY=${CROWDSEC_API_KEY}
    volumes:
      - caddy-data:/data
      - caddy-config:/config
      - caddy-logs:/var/log/caddy
      - ./Caddyfile:/etc/caddy/Caddyfile
    networks:
      - crowdsec
    restart: unless-stopped
    security_opt:
      - no-new-privileges=true

  crowdsec:
    image: docker.io/crowdsecurity/crowdsec:latest
    container_name: crowdsec
    environment:
      - GID=1000
      - COLLECTIONS=crowdsecurity/caddy crowdsecurity/http-cve crowdsecurity/whitelist-good-actors
      - BOUNCER_KEY_CADDY=${CROWDSEC_API_KEY}
    volumes:
      - crowdsec-db:/var/lib/crowdsec/data/
      - ./crowdsec/acquis.yaml:/etc/crowdsec/acquis.yaml
      - caddy-logs:/var/log/caddy:ro
    networks:
      - crowdsec
    restart: unless-stopped
    security_opt:
      - no-new-privileges=true

volumes:
  crowdsec-db:
  caddy-logs:
  caddy-data:
  caddy-config:

networks:
  crowdsec:
    driver: bridge

Three details matter here, all taken from the official Docker installation docs:

  1. COLLECTIONS is a space-separated list installed at first boot. crowdsecurity/caddy parses Caddy logs, crowdsecurity/http-cve adds CVE-exploit scenarios, and crowdsecurity/whitelist-good-actors keeps known-good crawlers and monitoring probes from getting banned.
  2. BOUNCER_KEY_CADDY seeds the Local API key for the Caddy bouncer at startup, so no manual cscli bouncers add step is needed. Generate the shared secret with tr -dc A-Za-z0-9 </dev/urandom | head -c 32 and store it in a .env file as CROWDSEC_API_KEY=....
  3. The caddy-logs volume is shared read-only into the CrowdSec container — this is how the engine sees your web traffic without any log-shipping plumbing.

The acquis.yaml tells CrowdSec which files to tail:

filenames:
  - /var/log/caddy/*.log
labels:
  type: caddy

And the Caddyfile registers the CrowdSec middleware plus JSON logging so every request is recorded in a parseable format:

{
    debug
    crowdsec {
        api_url http://crowdsec:8080
        api_key {$CROWDSEC_API_KEY}
    }
}

yourdomain.example.com {
    route {
        crowdsec
        reverse_proxy your-app:8080
    }
    log {
        output file /var/log/caddy/access.log
        format json
    }
}

The crowdsec directive inside the route block is the bouncer: every request is checked against the Local API before being proxied. Replace yourdomain.example.com and your-app:8080 with your real domain and upstream.

Building the Caddy Image with the Bouncer

Stock Caddy knows nothing about CrowdSec. You compile the bouncer in with xcaddy, exactly as the official example does:

ARG CADDY_VERSION=2

FROM caddy:${CADDY_VERSION}-builder-alpine AS builder

RUN xcaddy build \
    --with github.com/mholt/caddy-l4 \
    --with github.com/caddyserver/transform-encoder \
    --with github.com/hslatman/caddy-crowdsec-bouncer/http@main \
    --with github.com/hslatman/caddy-crowdsec-bouncer/layer4@main

FROM caddy:${CADDY_VERSION} AS caddy

WORKDIR /

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

Save this as Dockerfile in the project directory, generate the API key, and bring the stack up:

echo "CROWDSEC_API_KEY=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32)" > .env
docker compose up -d --build
docker logs crowdsec 2>&1 | tail -20

The logs should show collections installing and the Local API listening on port 8080. Give it a minute, then confirm the engine is healthy:

docker exec crowdsec cscli collections list
docker exec crowdsec cscli bouncers list

The bouncer list should show your Caddy bouncer registered via the BOUNCER_KEY_CADDY seed key.

Verifying Detection End to End

CrowdSec ships dummy test scenarios so you can prove the loop works without getting yourself banned. The official health-check guide documents the procedure; adapted for Docker behind Caddy:

  1. From a machine with a public IP (not your LAN — private IPs are whitelisted by default), request the probe path:
curl -I https://yourdomain.example.com/crowdsec-test-NtktlJHV4TfBSK3wvlhiOBnl
  1. Confirm the alert fired:
docker exec crowdsec cscli alerts list -s crowdsecurity/http-generic-test

If the alert appears, detection works: log line parsed, scenario matched, alert raised, decision streamed to the Caddy bouncer. If nothing appears, check that the Caddy access log is actually being written into the shared volume (docker exec crowdsec ls -la /var/log/caddy/) and that the acquisition file is loaded (docker exec crowdsec cscli acquis list).

For SSH protection on the host itself, install the engine natively via curl -s https://install.crowdsec.net | sudo sh and add the firewall bouncer (sudo apt install crowdsec-firewall-bouncer-iptables). The Docker engine protects your web traffic; the host engine protects SSH and every other exposed port.

Day-Two Operations: Console, Updates, and Tuning

Five habits keep the setup useful after day one — they mirror the official post-installation steps:

  • Enroll in the Console. Run docker exec crowdsec cscli console enroll <your-enroll-key> with a key from app.crowdsec.net. You get centralized alerts, stack health, and free community blocklists. It is the fastest way to see what CrowdSec is blocking while you sleep.
  • Watch decisions, not just alerts. docker exec crowdsec cscli decisions list shows active bans. Pair it with Uptime Kuma so you notice if a false positive ever blocks your monitoring probes.
  • Update collections regularly. docker exec crowdsec cscli hub update && docker exec crowdsec cscli hub upgrade pulls new scenarios and parsers. Do this monthly — attack patterns move fast.
  • Tune whitelists early. Private LAN ranges are whitelisted by default, but add your VPS monitoring IPs, uptime checkers, and AdGuard Home health checks if they hit web endpoints, or scheduled scans will eventually trip a scenario.
  • Upgrade the image deliberately. Pin to a specific version in production Compose files and test :latest moves in a staging stack. Between 1.6.x and 1.8.x there were breaking changes around data-directory persistence and bouncer APIs, so read the release notes before pulling a major bump.

Frequently Asked Questions

Does CrowdSec replace fail2ban? Mostly yes, and it goes further. fail2ban parses logs and bans locally with static rules; CrowdSec adds a scenario engine with hundreds of maintained collections, a real API between detection and blocking, and the crowdsourced blocklist. If you run only fail2ban today, migrating SSH protection to the CrowdSec firewall bouncer is a strict upgrade.

Will CrowdSec block legitimate users or my own monitoring? It can, which is why whitelists exist. Private LAN IPs are whitelisted out of the box, and crowdsecurity/whitelist-good-actors covers well-behaved crawlers. Add your uptime monitors and home IP range to a whitelist profile before enabling aggressive scenarios, then review cscli decisions list weekly for the first month.

How much RAM and CPU does the engine use? Very little — typically 50–150 MB RAM and negligible CPU on a homelab-scale log volume. It is orders of magnitude lighter than a full SIEM or a Prometheus-plus-Loki pipeline, which is why it fits comfortably on a Raspberry Pi or a small VPS alongside everything else.

Can I protect services that are not behind Caddy? Yes. Point any reverse proxy’s logs at CrowdSec (there are collections for nginx, Apache, Traefik, and others), use the matching WAF-capable bouncer, and use the firewall bouncer for non-HTTP services like SSH, SMTP, and databases. One engine can protect many log sources.

What happens if the CrowdSec container goes down? The Caddy bouncer fails open by default — requests pass through unchecked rather than taking your site offline. This is the correct tradeoff for a homelab, but set up container monitoring so you notice the outage instead of running unprotected for weeks.

Bottom Line

CrowdSec turns your reverse proxy logs from a forensic archive into an active defense layer: detect locally, block automatically, and learn globally from every other participant’s attacks. The Docker deployment is two containers, one shared log volume, and a seeded API key — roughly fifteen minutes of work for a permanent upgrade to your perimeter. Install it before you need it, verify detection with the dummy scenario, enroll in the Console, and let the crowd watch your back.