Closed xlionjuan closed 1 year ago
Hello @xlionjuan
I see that you are using live
mode.
With this you don't have to set thoses variables (below) for CAPI (central API) because it means you are running a LAPI crowdsec container which does processing of your logs.
crowdsecCapiMachineId: login
crowdsecCapiPassword: password
crowdsecCapiScenarios:
- crowdsecurity/http-path-traversal-probing
- crowdsecurity/http-xss-probing
- crowdsecurity/http-generic-bf
You do have to configure crowdsec to enable the scenario you want for instance like this:
crowdsec:
image: crowdsecurity/crowdsec:v1.5.3
container_name: "crowdsec"
restart: unless-stopped
environment:
COLLECTIONS: crowdsecurity/traefik
CUSTOM_HOSTNAME: crowdsec
# We need to register one api key per service we will use
BOUNCER_KEY_TRAEFIK: FIXME-LAPI-KEY-1=
volumes:
- ./acquis.yaml:/etc/crowdsec/acquis.yaml:ro
- logs:/var/log/traefik:ro
- crowdsec-db:/var/lib/crowdsec/data/
- crowdsec-config:/etc/crowdsec/
labels:
- "traefik.enable=false"
From this log and the last part statusCode:403, I think your connection to the crowdsec LAPI is not authenticated correctly.
DEBUG: CrowdsecBouncerTraefikPlugin: 2023/10/16 22:27:49 ServeHTTP:handleNoStreamCache ip:172.26.0.1 isBanned:true crowdsecQuery url:http://crowdsec:8080/v1/decisions?ip=172.26.0.1&banned=true, statusCode:403
Can you recrate a LAPI key and add it in the bouncer configuration ?
172.17.0.0/16
is usually the network range for docker.
if you see in the logs
ServeHTTP ip:172.26.0.1 isTrusted:false
It probably means the X-forwarded-for from the header is not picked up correctly
From Crowdsec logs:
time="16-10-2023 14:41:24" level=warning msg="failed to run filter : invalid character '.' after top-level value (1:1)\n | UnmarshalJSON(evt.Parsed.message, evt.Unmarshaled, \"traefik\") in [\"\", nil]\n | ^" id=restless-sun name=child-crowdsecurity/traefik-logs stage=s01-parse
It seams to receive some event but is not able to parse them.
Can you share your logging configuration of traefik ?
Did you add the parser for traefik ?
Installed with this env var for instance: COLLECTIONS: crowdsecurity/traefik
If you could provide your docker-compose (with the strict minimum) it could be helpful. In the meantime you may start from this one which is supposed to work well and test it with something like Whoami.
Hello @xlionjuan
I see that you are using
live
mode. With this you don't have to set thoses variables (below) for CAPI (central API) because it means you are running a LAPI crowdsec container which does processing of your logs.crowdsecCapiMachineId: login crowdsecCapiPassword: password crowdsecCapiScenarios: - crowdsecurity/http-path-traversal-probing - crowdsecurity/http-xss-probing - crowdsecurity/http-generic-bf
@mathieuHa Thank you, I only delete these lines and recreate LAPI key, and it can get the client's real IP again!
I didn't see "Mark as answer" button, maybe you can enable it?
Describe the bug 🐛 Logs from Traefik:
log from crowdsec:
Applications behind Traefik can get Real IP, whoani shows it can able get
X-Forwarded-For
andX-Real-Ip
, accesslog can get real IP also.cscli decisions add --ip 1.2.3.4 --duration 24h --reason "web bruteforce"
this command from Crowdsec can also ban my IPExpected behavior 👀 Get Real IP
Context 🔎 middlewares config:
Version (please complete the following information):
To Reproduce Steps to reproduce the behavior: