traefik-crowdsec-bouncer is an HTTP service to verify requests and bounce them according to decisions made by CrowdSec. Fork of https://github.com/fbonalair/traefik-crowdsec-bouncer with extra features.
Our images support multiple architectures such as x86-64, arm64 and armhf.
Simply pulling ghcr.io/thespad/traefik-crowdsec-bouncer should retrieve the correct image for your arch.
The architectures supported by this image are:
| Architecture | Available | Tag |
|---|---|---|
| x86-64 | ✅ | latest |
| arm64 | ✅ | latest |
| armhf | ❌ | latest |
docker exec -t crowdsec cscli bouncers add bouncer-traefikCROWDSEC_BOUNCER_API_KEY, or use an .env file.docker exec crowdsec cscli decisions add --ip <your ip> -R "Test Ban", modify the IP with your address.docker exec crowdsec cscli decisions delete --ip <your IP>Create a Forward Auth middleware, i.e.
middleware-crowdsec-bouncer:
forwardauth:
address: http://traefik-crowdsec-bouncer:8080/api/v1/forwardAuth
trustForwardHeader: true
Then apply it either to individual containers you wish to protect or as a default middlware on the Traefik listener.
Here are some example snippets to help you get started creating a container.
Compatible with docker-compose v2 schemas.
---
version: "2.1"
services:
traefik-crowdsec-bouncer:
image: ghcr.io/thespad/traefik-crowdsec-bouncer
container_name: traefik-crowdsec-bouncer
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
- CROWDSEC_BOUNCER_API_KEY=${TRAEFIK_BOUNCER_KEY}
- CROWDSEC_AGENT_HOST=crowdsec:8080
- CROWDSEC_BOUNCER_SCHEME=http #Optional
- TRUSTED_PROXIES=0.0.0.0/0 #Optional
- PORT=8080 #Optional
- CROWDSEC_BOUNCER_LOG_LEVEL=1 #Optional
- GIN_MODE=release #Optional
- CROWDSEC_BOUNCER_SKIPRFC1918=true #Optional
- CROWDSEC_BOUNCER_REDIRECT= #Optional
- CROWDSEC_BOUNCER_CLOUDFLARE=false #Optional
ports:
- 8080:8080
restart: unless-stopped
docker run -d \
--name=traefik-crowdsec-bouncer \
-e PUID=1000 \
-e PGID=1000 \
-e TZEurope/London \
-e CROWDSEC_BOUNCER_API_KEY=${TRAEFIK_BOUNCER_KEY} \
-e CROWDSEC_AGENT_HOST=crowdsec:8080 \
-e CROWDSEC_BOUNCER_SCHEME=http `#optional` \
-e TRUSTED_PROXIES=0.0.0.0/0 `#optional` \
-e PORT=8080 `#optional` \
-e CROWDSEC_BOUNCER_LOG_LEVEL=1 `#optional` \
-e GIN_MODE=release `#optional` \
-e CROWDSEC_BOUNCER_SKIPRFC1918=true `#optional` \
-e CROWDSEC_BOUNCER_REDIRECT= `#optional` \
-e CROWDSEC_BOUNCER_CLOUDFLARE=false `#optional` \
-p 8080:8080 \
--restart unless-stopped \
ghcr.io/thespad/traefik-crowdsec-bouncer
Container images are configured using parameters passed at runtime (such as those above). These parameters are separated by a colon and indicate <external>:<internal> respectively. For example, -p 8080:80 would expose port 80 from inside the container to be accessible from the host's IP on port 8080 outside the container.
| Parameter | Function |
|---|---|
-p 1935 | Web GUI |
-e PUID=1000 | for UserID - see below for explanation |
-e PGID=1000 | for GroupID - see below for explanation |
-e TZ=Europe/London | Specify a timezone to use EG America/New_York |
-e CROWDSEC_BOUNCER_API_KEY= | CrowdSec bouncer API key (required). |
-e CROWDSEC_AGENT_HOST= | Host and port of CrowdSec LAPI agent, i.e. crowdsec-agent:8080 (required). |
-e CROWDSEC_BOUNCER_SCHEME= | Scheme to query CrowdSec agent. Allowed values: http, https. Default is http. |
-e TRUSTED_PROXIES= | IP addresses of upstream proxies. Can accept a list of IP addresses in CIDR format, delimited by ','. Default is 0.0.0.0/0. |
-e PORT= | Change listening port of web server. Default is 8080. |
-e CROWDSEC_BOUNCER_LOG_LEVEL= | Minimum log level for bouncer. Allowed values: zerolog levels. Default is 1. |
-e GIN_MODE= | Operational mode for Gin framework. Set to debug for noisy log output. Default is release. |
-e CROWDSEC_BOUNCER_SKIPRFC1918= | Don't send RCF1918 (Private) IP addresses to the LAPI to check ban status. Allowed values: true, false . Default is true. |
-e CROWDSEC_BOUNCER_REDIRECT= | Optionally redirect instead of giving 403 Forbidden. Accepts relative or absolute URLs but must not be protected by the bouncer or you'll get a redirect loop. Default is null. |
-e CROWDSEC_BOUNCER_CLOUDFLARE= | Use the CF-Connecting-IP header instead of X-Forwarded-For. This is useful if you're using Cloudflare proxying as CF-Connecting-IP will contain the real source address rather than the Cloudflare address. Allowed values: true, false . Default is false. |
You can set any environment variable from a file by using a special prepend FILE__.
As an example:
-e FILE__PASSWORD=/run/secrets/mysecretpassword
Will set the environment variable PASSWORD based on the contents of the /run/secrets/mysecretpassword file.
For all of our images we provide the ability to override the default umask settings for services started within the containers using the optional -e UMASK=022 setting.
Keep in mind umask is not chmod it subtracts from permissions based on it's value it does not add. Please read up here before asking for support.
When using volumes (-v flags) permissions issues can arise between the host OS and the container, we avoid this issue by allowing you to specify the user PUID and group PGID.
Ensure any volume directories on the host are owned by the same user you specify and any permissions issues will vanish like magic.
In this instance PUID=1000 and PGID=1000, to find yours use id user as below:
$ id username
uid=1000(dockeruser) gid=1000(dockergroup) groups=1000(dockergroup)
docker exec -it traefik-crowdsec-bouncer /bin/bashdocker logs -f traefik-crowdsec-bouncerMost of our images are static, versioned, and require an image update and container recreation to update the app inside. We do not recommend or support updating apps inside the container. Please consult the Application Setup section above to see if it is recommended for the image.
Below are the instructions for updating containers:
docker-compose pull
docker-compose pull traefik-crowdsec-bouncerdocker-compose up -d
docker-compose up -d traefik-crowdsec-bouncerdocker image prunedocker pull ghcr.io/thespad/traefik-crowdsec-bouncerdocker stop traefik-crowdsec-bouncerdocker rm traefik-crowdsec-bouncer/config folder and settings will be preserved)docker image pruneIf you want to make local modifications to these images for development purposes or just to customize the logic:
git clone https://github.com/thespad/docker-traefik-crowdsec-bouncer.git
cd docker-traefik-crowdsec-bouncer
docker build \
--no-cache \
--pull \
-t ghcr.io/thespad/traefik-crowdsec-bouncer:latest .
Content type
Image
Digest
sha256:8b6dcb4b5…
Size
20.7 MB
Last updated
about 2 years ago
docker pull thespad/traefik-crowdsec-bouncer