Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - tennents

#1
I think i managed to do something...

first, backup the standard binary
cp /usr/local/bin/caddy /usr/local/bin/caddy.backup


download the new built binary with all the needed modules:

fetch -o /tmp/caddy-custom "https://caddyserver.com/api/download?os=freebsd&arch=amd64&p=github.com%2Fcaddy-dns%2Fcloudflare&p=github.com%2Fmholt%2Fcaddy-l4&p=github.com%2Fmholt%2Fcaddy-dynamicdns&p=github.com%2Fmholt%2Fcaddy-ratelimit&p=github.com%2Fcaddyserver%2Fntlm-transport&p=github.com%2Fhslatman%2Fcaddy-crowdsec-bouncer&idempotency=26094258780053"

fix permissions and move

chmod +x /tmp/caddy-custom
mv /tmp/caddy-custom /usr/local/bin/caddy


Now create a bouncer:
cscli bouncers add caddy-bouncer

save the API Key


then I created a .global file in /usr/local/etc/caddy/caddy.d

order crowdsec before reverse_proxy

crowdsec {
    api_url http://opnsense LAPI
    api_key key of the created bouncer
    ticker_interval 15s
}


then i had to add crowdsec in the handler.
unluckly it is not doable from the GUI, so I had to deactivate all my domain in the guy, create a .conf file in /usr/local/etc/caddy/caddy.d

my.domain.com {
        log {
                output file /var/log/caddy/access/b49df191-a08d-4f12-9834-bb15ceb8b3d0.log {
                        roll_keep_for 10d
                }
        }
        tls {
                issuer acme {
                        dns cloudflare API KEY CLOUDFLARE
                }
        }

        handle {
                crowdsec
                reverse_proxy ip:port {
                }
        }
}


it seems to work!


surely can be done in a more elegant way...
#2
Quote from: Monviech (Cedrik) on March 29, 2025, 12:31:14 PMThanks for looking into this.

It is feasable to add it but I dont really want to add it since every compiled package more just makes maintanance harder in the long run.

Though there is always "caddy add-package" for the more adventurous :)

Hi
sorry to bump this old post... but I'm in the same exact situation (Cloudflare proxy --> OPNSense --> Caddy plugin) and I'd like to understand how to implement the bouncer directly in caddy.

I can test and break my installation if needed... can you provide a step-by-step? thanks!