Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ad8d0509a | ||
|
|
aac117f594 | ||
|
|
e34a0e909d |
+6
-8
@@ -233,16 +233,15 @@ 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"
|
||||
|
||||
## Enable Anubis GeoIP detection
|
||||
#COMPOSE_FILE="$COMPOSE_FILE:compose.anubis-geoip.yml"
|
||||
# YAML list of blocked ASNs
|
||||
#ANUBIS_GEOIP_BLOCKED_ASNS='[13335,136907,45102]'
|
||||
# YAML list of blocked countries
|
||||
#ANUBIS_GEOIP_BLOCKED_COUNTRIES='[BR,CN,VN]'
|
||||
|
||||
## Enable onion service support
|
||||
#ONION_ENABLED=1
|
||||
|
||||
@@ -266,4 +265,3 @@ WRITE_TIMEOUT=0s
|
||||
#RATE_LIMIT_AVERAGE=100
|
||||
#RATE_LIMIT_BURST=200
|
||||
#RATE_LIMIT_PERIOD=1s
|
||||
|
||||
|
||||
@@ -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`.
|
||||
```
|
||||
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
|
||||
```
|
||||
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
|
||||
export ENTRYPOINT_VERSION=v5
|
||||
export ANUBIS_YML_VERSION=v2
|
||||
export ANUBIS_YML_VERSION=v1
|
||||
export CROWDSEC_TRAEFIK_CONFIG_VERSION=v1
|
||||
|
||||
@@ -1,35 +1,7 @@
|
||||
bots:
|
||||
{{ if eq (env "ANUBIS_GEOIP_ENABLED") "true" }}
|
||||
{{ if ne (env "ANUBIS_GEOIP_BLOCKED_ASNS") "" }}
|
||||
- name: blocked-asns
|
||||
action: WEIGH
|
||||
asns:
|
||||
match: {{ env "ANUBIS_GEOIP_BLOCKED_ASNS" }}
|
||||
weight:
|
||||
adjust: 10
|
||||
{{ end }}
|
||||
{{ if ne (env "ANUBIS_GEOIP_BLOCKED_COUNTRIES") "" }}
|
||||
- name: countries-with-aggressive-scrapers
|
||||
action: WEIGH
|
||||
geoip:
|
||||
countries: {{ env "ANUBIS_GEOIP_BLOCKED_COUNTRIES" }}
|
||||
weight:
|
||||
adjust: 10
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
- import: (data)/meta/default-config.yaml
|
||||
{{ if eq (env "ANUBIS_METRICS_ENABLED") "true" }}
|
||||
metrics:
|
||||
bind: ":9090"
|
||||
network: "tcp"
|
||||
{{ end }}
|
||||
{{ if eq (env "ANUBIS_GEOIP_ENABLED") "true" }}
|
||||
geoip:
|
||||
asn:
|
||||
path: /var/lib/anubis/GeoLite2-ASN.mmdb
|
||||
country:
|
||||
path: /var/lib/anubis/GeoLite2-Country.mmdb
|
||||
logging:
|
||||
sink: stdio
|
||||
asn: true
|
||||
{{ end }}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
---
|
||||
version: "3.8"
|
||||
services:
|
||||
anubis:
|
||||
environment:
|
||||
ANUBIS_GEOIP_ENABLED: "true"
|
||||
volumes:
|
||||
- "anubis-geoip:/var/lib/anubis/:ro"
|
||||
volumes:
|
||||
anubis-geoip:
|
||||
@@ -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/
|
||||
- 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
|
||||
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
|
||||
{{- end }}
|
||||
|
||||
Reference in New Issue
Block a user