lucaslorentz / caddy-docker-proxy

Caddy as a reverse proxy for Docker
MIT License
2.86k stars 168 forks source link

Q: How to define global snippets? #541

Closed FunctionDJ closed 9 months ago

FunctionDJ commented 11 months ago

Sorry for creating an issue, i don't know where else to ask.

My current Caddyfile uses snippets a lot for my containers.

I'd like to define them globally so that they're always available, so where do i define them? Do i create them on the Caddy container itself because when the labels come into action the Caddy container is always up anyway?

Almost all of my containers are managed through separate docker-compose.yaml files, is that an issue? Can i just use the snippets from labels of other containers like that?

emilylange commented 11 months ago

You can use CADDY_DOCKER_CADDYFILE_PATH (-caddyfile-path) and throw your snippets into that. Adding your snippets to the caddy container as labels works as well, yes.

Snippets are global.

lucaslorentz commented 9 months ago

Yeah, there is the option @emilylange mentioned.

If you're using docker swarm, you could alternatively create a Docker Config with the Caddyfile content you want and add label caddy to the config. Like this

Alternatively, you can also add caddy labels that generate the snippet to any container/service, including Caddy container/service itself. Containers/services can use snippets from other container/services, they all end up in same Caddyfile.

FunctionDJ commented 7 months ago

Thank you for the replies, i'll try to get it working ^^'