lucaslorentz / caddy-docker-proxy

Caddy as a reverse proxy for Docker
MIT License
2.89k stars 170 forks source link

Add Sablier Plugin version? #498

Closed ameeno closed 1 year ago

ameeno commented 1 year ago

Hello.

I've become very interested in putting my high cpu/ram using docker containers to sleep when there is no traffic. My search has led me to a traefik plugin called Sablier, which aims to shut down/ put to sleep docker containers when not used by acting like a middleware.

recently Sablier has added a beta caddy plugin in this PR: Caddy reverse proxy integration

Now i wonder if it is possible to have this docker proxy add Sablier support and configuration via labels to put containers to sleep when they do not receive traffic after a while.

Obviously this should be completely optional and the feature should be off by default with the ability to specifically enable it manually on containers you want to.

Ideally i should be able to create an import for this feature similarly to how I create an import for authelia. (see example):

on caddy-docker-proxy container:
    labels:
      caddy_0: (auth)
      caddy_0.forward_auth: <MY_AUTHELIA_CONTAINER_AND:PORT>
      caddy_0.forward_auth.uri: /api/verify?rd=https://<MY_DOMAIN>
      caddy_0.forward_auth.copy_headers: Remote-User Remote-Groups Remote-Name Remote-Email
      caddy_0.forward_auth.import: trusted_proxy_list

on individual containers:
    labels:
      caddy.reverse_proxy.import: trusted_proxy_list
      caddy.import: auth

My idea is if i can create a similar label config for sablier usage, and import that as needed to specific containers, a plugin with caddy/sablier built in would be an awesome new feature.

what do you guys think?

lucaslorentz commented 1 year ago

Hey. Didn't know Sablier. Looks interesting.

Didn't have time to dig much, but I think everything will work out of the box if you give it a try.

Build a custom docker image with both caddy-docker-proxy and Sablier plugins.

You can generate Sablier configs using labels like:

caddy.sablier.group = mygroup
caddy.sablier.dynamic =

I found some info in this readme: https://github.com/acouvreur/sablier/blob/c3518ff6ba362c11837a55d19f06a971066e3661/plugins/caddy/README.md from the pull request.

lucaslorentz commented 1 year ago

More info on how to create labels: https://github.com/lucaslorentz/caddy-docker-proxy#labels-to-caddyfile-conversion