WIP: feat: adds crowdsec #122

Draft
devydave wants to merge 3 commits from devydave/traefik:feat-crowdsec into master
Owner

We were in urgent need of some DDOS protection, because one of our projects got attacked. This is the solution that is currently running as a mitigation in production.
Feel free to review :)

We were in urgent need of some DDOS protection, because one of our projects got attacked. This is the solution that is currently running as a mitigation in production. Feel free to review :) * [x] I have deployed and tested my changes * [x] I have [updated relevant versions in `abra.sh`](https://docs.coopcloud.tech/maintainers/upgrade/#updating-versions-in-the-abrash) * [ ] I have made my environment variable changes [backwards compatible](https://docs.coopcloud.tech/maintainers/upgrade/#backwards-compatible-environment-variable-changes) * [ ] I have added a [release note entry](https://docs.coopcloud.tech/maintainers/upgrade/#creating-new-release-notes)
devydave added 1 commit 2026-07-18 11:08:41 +00:00
feat: adds crowdsec
continuous-integration/drone/pr Build is failing
e34a0e909d
@@ -1,3 +1,4 @@
export TRAEFIK_YML_VERSION=v32
export FILE_PROVIDER_YML_VERSION=v12
export TRAEFIK_YML_VERSION=v33
export FILE_PROVIDER_YML_VERSION=v15
Author
Owner

will fix the version skip when I have more time ^^

will fix the version skip when I have more time ^^
devydave marked this conversation as resolved
devydave marked the pull request as work in progress 2026-07-28 20:45:22 +00:00
Owner

@devydave can you rebase and integrate the access log feature from fauno?

@devydave can you rebase and integrate the access log feature from fauno?
Owner

@devydave can you rebase and integrate the access log feature from fauno?

@devydave can you rebase and integrate the access log feature from fauno?
Owner

@hex here's previous art on getting a waf into traefik

@hex here's previous art on getting a waf into traefik
Author
Owner

@hex @fauno if there is more interest I can try to finish it, we do not use it anymore at the moment but the recent CVE problems showed it would be nice to have

@hex @fauno if there is more interest I can try to finish it, we do not use it anymore at the moment but the recent CVE problems showed it would be nice to have
Owner

The brotli issue would be far from solved with a WAF, but a WAF would definitely reduce the attack surface. I do think it would help.

The brotli issue would be far from solved with a WAF, but a WAF would definitely reduce the attack surface. I do think it would help.
Owner

@devydave i think this is only working option for traefik so far in term of wafs, right? i've been looking into coraza but the open source plugin is unmaintained and the production plugin is for traefik enterprise edition. it'd be great if you had the time to finish it, otherwise i can try soon!

@devydave i think this is only working option for traefik so far in term of wafs, right? i've been looking into coraza but the open source plugin is unmaintained and the production plugin is for traefik enterprise edition. it'd be great if you had the time to finish it, otherwise i can try soon!
devydave added 1 commit 2026-11-08 18:53:05 +00:00
Merge branch 'master' into feat-crowdsec
continuous-integration/drone/pr Build is failing
aac117f594
devydave added 1 commit 2026-11-08 20:19:41 +00:00
refactor: refactor to new access log implementation
continuous-integration/drone/pr Build is failing
5ad8d0509a
@@ -78,0 +114,4 @@
When there are not bans yet you can try by banning your own IP.
```
abra app run <domain> crowdsec cscli decisions add --ip <your-ip> -d 10m # this will be effective 10min
Author
Owner

This command is not working at the moment because the flags get parsed as abra flags and when I wrap them in " the cli is not found inside the container. For me it feels like a bug ideas anyone?

This command is not working at the moment because the flags get parsed as abra flags and when I wrap them in " the cli is not found inside the container. For me it feels like a bug ideas anyone?
Owner

would you try any of these combinations?

toolshed/abra#790

would you try any of these combinations? https://git.coopcloud.tech/toolshed/abra/issues/790
Author
Owner

@fauno I adjusted the PR with your access log changes with the following env it works. Maybe I will adjust the pattern like the access log that CROWDSEC_ENABLED is not needed.

COMPOSE_FILE="$COMPOSE_FILE:compose.access-log.yml"

COMPOSE_FILE="$COMPOSE_FILE:compose.crowdsec.yml"
CROWDSEC_ENABLED=1
CROWDSEC_BOUNCER_ENABLED=1
SECRET_CROWDSEC_LAPI_KEY_VERSION=v2

What will be your use case for the crowdsec integration? When you enable it on a service the traefik logs get scanned for patterns and bans sus behaviour and bans the IP for 4h. A ban results in a 403 being sent. There is an option for captcha, that could be implemented.
image.png

@fauno I adjusted the PR with your access log changes with the following env it works. Maybe I will adjust the pattern like the access log that `CROWDSEC_ENABLED` is not needed. ``` COMPOSE_FILE="$COMPOSE_FILE:compose.access-log.yml" COMPOSE_FILE="$COMPOSE_FILE:compose.crowdsec.yml" CROWDSEC_ENABLED=1 CROWDSEC_BOUNCER_ENABLED=1 SECRET_CROWDSEC_LAPI_KEY_VERSION=v2 ``` What will be your use case for the crowdsec integration? When you enable it on a service the traefik logs get scanned for patterns and bans sus behaviour and bans the IP for 4h. A ban results in a 403 being sent. There is an option for captcha, that could be implemented. ![image.png](/attachments/6a800536-39c3-4d73-b896-ff0223d0c557)
@@ -77,1 +77,4 @@
## Crowdsec
IMPORTANT even though Crowdsec is Open Source, the software sends information of the attacker IP and what decision(ban or captcha) to a centralized server for communit managed block lists.
Owner

there's a typo in communit[y]. also, does it mean to say that any visitor ip address is sent to crowdsec? or is there a local decision about what looks like an attack?

there's a typo in communit[y]. also, does it mean to say that any visitor ip address is sent to crowdsec? or is there a local decision about what looks like an attack?
Author
Owner

I did not find out to configure it yet, but there are both options. You can only make decisions locally and do not upstream the IP, but then you do not get access to the full provided community ban list. The other option is you upstream the IPs which get banned and get full access to the ban list.

I did not find out to configure it yet, but there are both options. You can only make decisions locally and do not upstream the IP, but then you do not get access to the full provided community ban list. The other option is you upstream the IPs which get banned and get full access to the ban list.
@@ -78,0 +91,4 @@
abra app run <domain> crowdsec cscli bouncers add crowdsecBouncer
```
After that insert the LAPI key(command below) and redeploy traefik with `CROWDSEC_BOUNCER_ENABLED=1` and `CROWDSEC_TRAEFIK_CONFIG_VERSION=v2`.
Owner

did you actually need to increase the config version? the template doesn't change so docker should accept it even if the rendered config is different

did you actually need to increase the config version? the template doesn't change so docker should accept it even if the rendered config is different
Author
Owner

Oh yeah that is a mistake

Oh yeah that is a mistake
@@ -0,0 +13,4 @@
COLLECTIONS: "crowdsecurity/traefik"
volumes:
- crowdsec-db:/var/lib/crowdsec/data/
- crowdsec-config:/etc/crowdsec/
Owner

what does this volume store?

what does this volume store?
@@ -25,0 +27,4 @@
plugin:
bouncer:
enabled: {{ if eq (env "CROWDSEC_BOUNCER_ENABLED") "1" }}true{{ else }}false{{ end }}
logLevel: DEBUG
Owner

can this be made configurable?

can this be made configurable?
Author
Owner

Sure, also this is in by mistake from a debugging session, I think the default should be INFO?

Sure, also this is in by mistake from a debugging session, I think the default should be INFO?
@@ -191,0 +197,4 @@
plugins:
bouncer:
moduleName: github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin
version: v1.8.1
Owner

do the versions need to match?

do the versions need to match?
Author
Owner

I think this is a coincendence

I think this is a coincendence
Some required checks failed
continuous-integration/drone/pr Build is failing
You are not authorized to merge this pull request.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
This pull request is marked as a work in progress.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u https://git.coopcloud.tech/devydave/traefik feat-crowdsec:devydave-feat-crowdsec
git checkout devydave-feat-crowdsec
Sign in to join this conversation.