CrowdSec

Overview

CrowdSec is a collaborative intrusion detection and prevention system integrated directly into Traefik. It analyses Traefik access logs in real time, detects attack patterns (brute force, CVE exploitation, bad bots, etc.), and instructs Traefik to block flagged IPs before they reach any backend service.

The stack consists of two containers:

Access

Neither CrowdSec container has a web UI. Management is via the cscli CLI inside the crowdsec container:

docker exec -it crowdsec cscli decisions list
docker exec -it crowdsec cscli alerts list
docker exec -it crowdsec cscli metrics

Configuration

Compose project: crowdsec (managed via Portainer)

Containers

crowdsec — Security Engine

Image: crowdsecurity/crowdsec:latest

Property Value
Network traefik-net
Restart policy unless-stopped

Key environment variables:

Variable Value / Notes
GID 1000
COLLECTIONS crowdsecurity/traefik crowdsecurity/http-cve crowdsecurity/whitelist-good-actors
BOUNCER_KEY_TRAEFIK REDACTED — shared secret used by the bouncer to authenticate with LAPI

Collections installed:

Collection Purpose
crowdsecurity/traefik Detects attack patterns in Traefik access logs
crowdsecurity/http-cve Detects exploitation of known HTTP CVEs
crowdsecurity/whitelist-good-actors Whitelists known-good crawlers and services

crowdsec-bouncer-traefik — Traefik Bouncer

Image: fbonalair/traefik-crowdsec-bouncer:latest

Property Value
Network traefik-net
Internal port 8080 (ForwardAuth endpoint)

Key environment variables:

Variable Value / Notes
GIN_MODE release
CROWDSEC_AGENT_HOST crowdsec:8080 — CrowdSec LAPI endpoint
CROWDSEC_BOUNCER_API_KEY REDACTED — must match BOUNCER_KEY_TRAEFIK

How the Bouncer Integrates with Traefik

The middleware is defined in /home/jeeves/docker/traefik/config/crowdsec.yml:

http:
  middlewares:
    crowdsec-bouncer:
      forwardAuth:
        address: http://crowdsec-bouncer-traefik:8080/api/v1/forwardAuth
        trustForwardHeader: true

This middleware is referenced on external Traefik routes as crowdsec-bouncer@file.

Log Ingestion

CrowdSec reads Traefik access logs from two bind-mounted paths:

Host Path Container Path Notes
/var/log/traefik /var/log/traefik:ro Primary log location
/home/jeeves/docker/traefik/logs /logs/traefik:ro Secondary / rotated logs

The acquis.yaml config file at /home/jeeves/docker/crowdsec/config/acquis.yaml defines which log files to tail and in what format.

Volumes / Bind Mounts

Host Path Container Path Purpose
/home/jeeves/docker/crowdsec/data /var/lib/crowdsec/data Decision database and GeoIP data
/home/jeeves/docker/crowdsec/config /etc/crowdsec Scenarios, parsers, config
/var/log/traefik /var/log/traefik:ro Traefik access log (read-only)
/home/jeeves/docker/traefik/logs /logs/traefik:ro Traefik rotated logs (read-only)

Dependencies

Notes / Gotchas


Last Updated: 2026-06-16


Revision #1
Created 2026-06-17 00:30:15 UTC by Admin
Updated 2026-06-17 00:31:19 UTC by Admin