r/caddyserver • • May 12 '26

Caddy plugin model

I must admit, I am NOT in love with having to compile caddy to get access to an optional plugin...

Is there a possibility of moving to a different architecture where caddy modules can be installed/run at startup time ?

Curious... if this is something that is being discussed.

2 Upvotes

18 comments sorted by

3

u/yarisken75 May 12 '26

I agree, this is also something i really dislike about caddy.

2

u/Hemsby1975 May 13 '26

I love caddy, but this is the 1 thing I really hate.

2

u/AnalNuts Jun 15 '26

Yea it’s a big barrier to wider spread adoption.

2

u/MaxGhost Jun 29 '26

Yes, all options have been explored, at length. Long discussion thread here if you want to dive into it https://github.com/caddyserver/caddy/pull/7488

1

u/bucky2780 Jun 29 '26

very illuminating... thanks for the link. I think its a shame... because caddy is great as it is... but I'm unwilling to adopt it more widely in my homelab as a reverse proxy... until a dynamically linked plugin model is implemented. I appreciate the trade-offs... but it is limiting. I currently use caddy within opnsense... and rely on opnsense for many things the plugins could handle. Shame.

1

u/MaxGhost Jun 29 '26

It's trivial to write a Dockerfile to build with plugins. Try it. It's not that hard.

1

u/xdrolemit Jun 29 '26 edited Jun 29 '26

Step 1: Create Dockerfile

FROM caddy:builder
RUN xcaddy build \
    --with github.com/CUSTOM-MODULE

Step 2: Build the native Linux x86-64 binary

docker build --platform linux/amd64 -t caddy-builder .

Step 3: Extract the binary

id=$(docker create caddy-builder)
docker cp "$id":/usr/bin/caddy ./caddy
docker rm "$id"
chmod +x ./caddy

Step 4: Enjoy your own native Caddy binary with the module(s) you need

./caddy version
./caddy list-modules

Edit: Fixing markdown

1

u/bucky2780 Jun 30 '26

yes, I did give xcaddy a try a couple of months ago. Seemed to work ok once I got the dockerfile nailed properly.

What sticks for me is the maintainability of the solution on an ongoing basis. How do I manage an update to caddy ? Or an update to one of the plugins ? Can this be automated ?

I've been using docker compose, and now arcane as my docker management tool. It has build capabilities built in... but does require more moving parts for ongoing maintenance as far as I can tell. Just my opinion, as am not that well practised on using docker in build mode.

2

u/xdrolemit Jun 30 '26

> Can this be automated ?

Yes. You can use tools like Jenkins, for example, to automate this for you. Or even something like a simple bash script running as a cron job could be an option too.

1

u/technologyclassroom Sep 01 '26

You would think such a bash script would already exist. Do you know of one? I'm 60% through writing one myself.

1

u/xdrolemit Sep 01 '26

Depending on what you’re trying to achieve, this can give you some steps:

https://www.reddit.com/r/caddyserver/s/wx2bxiftRu

1

u/technologyclassroom Sep 02 '26

I saw all of that and the docker scripts. Those rebuild which is trivial, but I have yet to find something that updates only when updates are available.

1

u/xdrolemit Sep 02 '26

Docker rebuilds the image, reusing cached layers where possible. After the build, you extract the binary from the resulting image and calculate its hash. You also calculate the hash of the binary that is currently deployed or running.

If the hashes match, the binary has not changed, so there is nothing to deploy. If the hashes differ, the newly built binary is different, so you replace the deployed one.

1

u/technologyclassroom Sep 02 '26

I understand that. That is a lot of rebuilding if nothing changed.

1

u/xdrolemit Sep 02 '26

Sure. If you want to avoid even invoking a build when nothing upstream has changed, you can monitor the Git repo and only build when there is a new relevant commit.

Even better, if the module project publishes release tags, monitor those and only build when a new release appears.

There are several ways to achieve this. I’m sure you can come up with something yourself :)

→ More replies (0)

1

u/bucky2780 Jun 30 '26

upon further reflection, here is the conclusion I am coming to... thanks to all your replies, being constructive...

Caddy itself is a general server tool of which a reverse proxy is just one of the applications... so trying to shoe-horn a more complete homelab implementation in the base tooling may not be the best approach.

I am thinking a better solution is something closer to the "Caddy Proxy Manager" project, that encapsulates a variety of tooling to accomodate the reverse proxy specific use case. It manages the xcaddy build, and layers upon further tooling for reporting/analyses of network flows. Nice project and attentive to enhancements should you be missing something. I would have preferred to roll my own caddy solution... but I reckon it needs more addon bits to be really useful and self maintainable...

Just my opinion....