WIP: feat: adds crowdsec #122
@@ -233,6 +233,12 @@ WRITE_TIMEOUT=0s
|
||||
#ANUBIS_SERVE_ROBOTS_TXT=true
|
||||
#ANUBIS_SLOG_LEVEL=INFO
|
||||
|
||||
## Crowdsec
|
||||
#COMPOSE_FILE="$COMPOSE_FILE:compose.crowdsec.yml"
|
||||
#CROWDSEC_ENABLED=1
|
||||
#CROWDSEC_BOUNCER_ENABLED=1
|
||||
#SECRET_CROWDSEC_LAPI_KEY_VERSION=v1 # generate=false
|
||||
|
||||
## Anubis metrics
|
||||
#COMPOSE_FILE="$COMPOSE_FILE:compose.anubis-metrics.yml"
|
||||
|
||||
|
||||
@@ -75,6 +75,52 @@ protection your apps.**
|
||||
If you want to collect Prometheus metrics for Anubis, for instance with
|
||||
[monitoring-ng](/monitoring-ng), uncomment the "Anubis metrics" section.
|
||||
|
||||
## 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.
|
||||
|
|
||||
|
||||
On first deployment you need to generate an empty secret, because the lapi key is created at runtime.
|
||||
```
|
||||
abra app secret insert <domain> crowdsec_lapi_key v1
|
||||
```
|
||||
|
||||
Then deploy your traefik recipe with the crowdsec compose and variables enabled and set `CROWDSEC_BOUNCER_ENABLED=0` to prevent initializing the bouncer that has no key yet.
|
||||
|
||||
When traefik is running, generate the LAPI key with the following command:
|
||||
```
|
||||
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`.
|
||||
|
fauno
commented
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
devydave
commented
Oh yeah that is a mistake Oh yeah that is a mistake
|
||||
```
|
||||
abra app secret insert <domain> crowdsec_lapi_key v2 -f -t <path-to/lapi-key-file>
|
||||
```
|
||||
|
||||
When it is up and running go to the recipe you want to protect and add the following snippet and redeploy.
|
||||
```
|
||||
---
|
||||
version: "3.8"
|
||||
services:
|
||||
app:
|
||||
deploy:
|
||||
labels:
|
||||
- "traefik.http.routers.${STACK_NAME}.middlewares=crowdsec@file"
|
||||
```
|
||||
|
||||
You can see if it is working by checking the ban list.
|
||||
```
|
||||
abra app run <domain> crowdsec cscli decisions list
|
||||
```
|
||||
|
||||
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
|
||||
|
devydave
commented
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?
fauno
commented
would you try any of these combinations? would you try any of these combinations?
https://git.coopcloud.tech/toolshed/abra/issues/790
|
||||
```
|
||||
Remove it with:
|
||||
```
|
||||
abra app run <domain> crowdsec cscli decisions remove --ip <your-ip> # this can still take a few minutes because of cache
|
||||
```
|
||||
|
||||
## Enabling onion service
|
||||
|
||||
Uncomment the line in the config setting `ONION_ENABLED=1`. This will create a new entrypoint on port 9052 which can be used to bypass forced SSL. For more details, see the [onion recipe](https://recipes.coopcloud.tech/onion).
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export TRAEFIK_YML_VERSION=v37
|
||||
export FILE_PROVIDER_YML_VERSION=v14
|
||||
export TRAEFIK_YML_VERSION=v38
|
||||
export FILE_PROVIDER_YML_VERSION=v15
|
||||
|
devydave marked this conversation as resolved
devydave
commented
will fix the version skip when I have more time ^^ will fix the version skip when I have more time ^^
|
||||
export ENTRYPOINT_VERSION=v5
|
||||
export ANUBIS_YML_VERSION=v1
|
||||
export CROWDSEC_TRAEFIK_CONFIG_VERSION=v1
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
version: "3.8"
|
||||
services:
|
||||
app:
|
||||
deploy:
|
||||
labels:
|
||||
- "traefik.http.routers.${STACK_NAME}.middlewares=crowdsec@file"
|
||||
secrets:
|
||||
- crowdsec_lapi_key
|
||||
crowdsec:
|
||||
image: crowdsecurity/crowdsec:v1.8.2
|
||||
environment:
|
||||
GID: "${GID-1000}"
|
||||
COLLECTIONS: "crowdsecurity/traefik"
|
||||
volumes:
|
||||
- crowdsec-db:/var/lib/crowdsec/data/
|
||||
- crowdsec-config:/etc/crowdsec/
|
||||
|
fauno
commented
what does this volume store? what does this volume store?
|
||||
- access-logs:/var/log/traefik/:ro
|
||||
configs:
|
||||
- source: crowdsec_traefik_config
|
||||
target: /etc/crowdsec/acquis.d/traefik_config.yaml
|
||||
mode: 0555
|
||||
networks:
|
||||
- internal
|
||||
deploy:
|
||||
update_config:
|
||||
failure_action: rollback
|
||||
order: stop-first
|
||||
|
||||
configs:
|
||||
crowdsec_traefik_config:
|
||||
name: ${STACK_NAME}_crowdsec_traefik_${CROWDSEC_TRAEFIK_CONFIG_VERSION}
|
||||
file: crowdsec_traefik_config.yaml.tmpl
|
||||
template_driver: golang
|
||||
|
||||
secrets:
|
||||
crowdsec_lapi_key:
|
||||
external: true
|
||||
name: ${STACK_NAME}_crowdsec_lapi_key_${SECRET_CROWDSEC_LAPI_KEY_VERSION}
|
||||
|
||||
volumes:
|
||||
crowdsec-db:
|
||||
crowdsec-config:
|
||||
@@ -0,0 +1,5 @@
|
||||
filenames:
|
||||
- /var/log/traefik/*
|
||||
labels:
|
||||
type: traefik
|
||||
|
||||
@@ -22,6 +22,16 @@ http:
|
||||
basicAuth:
|
||||
usersFile: "/run/secrets/usersfile"
|
||||
{{ end }}
|
||||
{{ if eq (env "CROWDSEC_ENABLED") "1" }}
|
||||
crowdsec:
|
||||
plugin:
|
||||
bouncer:
|
||||
enabled: {{ if eq (env "CROWDSEC_BOUNCER_ENABLED") "1" }}true{{ else }}false{{ end }}
|
||||
logLevel: DEBUG
|
||||
|
fauno
commented
can this be made configurable? can this be made configurable?
devydave
commented
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?
|
||||
crowdsecMode: live
|
||||
crowdsecLapiKey: "{{ if eq (env "CROWDSEC_BOUNCER_ENABLED") "1" }}{{ secret "crowdsec_lapi_key" }}{{ else }}please_set_CROWDSEC_BOUNCER_ENABLED_to_1{{ end }}"
|
||||
crowdsecLapiHost: crowdsec:8080
|
||||
{{ end }}
|
||||
ip-rate-limit:
|
||||
rateLimit:
|
||||
average: {{ or (env "RATE_LIMIT_AVERAGE") "100" }}
|
||||
|
||||
@@ -5,6 +5,9 @@ core:
|
||||
log:
|
||||
level: {{ env "LOG_LEVEL" }}
|
||||
maxAge: {{ env "LOG_MAX_AGE" }}
|
||||
{{- if eq (env "CROWDSEC_ENABLED") "1" }}
|
||||
filePath: "/var/log/traefik.log"
|
||||
{{- end }}
|
||||
|
||||
{{ if eq (env "ACCESS_LOG_ENABLED") "true" }}
|
||||
accessLog:
|
||||
@@ -188,3 +191,11 @@ certificatesResolvers:
|
||||
- "1.1.1.1:53"
|
||||
- "9.9.9.9:53"
|
||||
{{- end }}
|
||||
|
||||
{{ if eq (env "CROWDSEC_ENABLED") "1" }}
|
||||
experimental:
|
||||
plugins:
|
||||
bouncer:
|
||||
moduleName: github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin
|
||||
version: v1.8.1
|
||||
|
fauno
commented
do the versions need to match? do the versions need to match?
devydave
commented
I think this is a coincendence I think this is a coincendence
|
||||
{{- end }}
|
||||
|
||||
Reference in New Issue
Block a user
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?
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.