Crowdsec not working with Caddy Plugin

Hi.
Im trying to use this bouncer (GitHub - hslatman/caddy-crowdsec-bouncer: A Caddy module that blocks malicious traffic based on decisions made by CrowdSec.).
I install it, also crowdsec, enroll the server, etc.
I see this in crowdsec:
image

So, it seems crowdsec is fine.
I compile with xcaddy and also seems working:
caddy version v2.7.6
caddy list-modules result:

  Standard modules: 106

crowdsec

  Non-standard modules: 1

I put this in my Caddyfile:

{
    crowdsec {
        api_url http://localhost:8080
        api_key 3xxx6xxxxxxxxxxxxxxxxx3fd
        ticker_interval 15s
        #disable_streaming
        #enable_hard_fails
    }

}

trilium.xxxxxxxxx.xyz {
        reverse_proxy crowdsec 192.168.0.10:8080

        log {
        output file /var/log/caddy/trilium-access.log {
        roll_size 10mb
        roll_keep 20
        roll_keep_for 720h
  }
}
}

But… when try to access i get an error:
{"level":"error","ts":1716596310.84049,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"185.23.45.80","remote_port":"53294","client_ip":"185.23.45.80","proto":"HTTP/2.0","method":"GET","host":"trilium.xxxxxx.xyz","uri":"/","headers":{"Sec-Fetch-Mode":["navigate"],"Sec-Fetch-User":["?1"],"Sec-Fetch-Dest":["document"],"Sec-Ch-Ua-Mobile":["?0"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"],"Sec-Fetch-Site":["none"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Sec-Ch-Ua":["\"Not-A.Brand\";v=\"99\", \"Chromium\";v=\"124\""],"Sec-Ch-Ua-Platform":["\"Linux\""],"Accept-Language":["en-US,en;q=0.9"],"Priority":["u=0, i"]},"tls":{"resumed":false,"version":772,"cipher_suite":4867,"proto":"h2","server_name":"trilium.xxxxxxxx.xyz"}},"bytes_read":0,"user_id":"","duration":0.004853857,"size":0,"status":502,"resp_headers":{"Server":["Caddy"],"Alt-Svc":["h3=\":443\"; ma=2592000"]}}

Hope you can help me.
Thanks!

This doesn’t make sense. Here, you’re defining two different upstreams for the proxy, i.e. crowdsec and 192.168.0.10:8080. I figure crowdsec is not a real upstream.

I don’t have a clue how Crowdsec is meant to work, I don’t use that plugin. So you’ll need to ask for help from the Crowdsec authors (open an issue on the github repo).

Also, you didn’t fill out the help topic template as per the forum rules. Your logs are incomplete, we need to see more than just that one error message, there will be more to show in your logs, especially if you enable the debug global option.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.