lucaslorentz / caddy-docker-proxy

Caddy as a reverse proxy for Docker
MIT License
2.61k stars 163 forks source link

Add an manual written base config #597

Closed sowinski closed 3 months ago

sowinski commented 3 months ago

Hi,

I have a list of 100 domains which I want to redirect to my main domains which we use.

I could add them all with labels. But I would like to write a script which is generating a base config file, which only includes this redirects. Everything else, should be still working with labels.

Here you write, that this is only for docker swarm https://github.com/lucaslorentz/caddy-docker-proxy?tab=readme-ov-file#docker-configs

Now I am unsure what would be the best practice in this case?

francislavoie commented 3 months ago

See https://github.com/lucaslorentz/caddy-docker-proxy?tab=readme-ov-file#caddy-cli, you can set up the CADDY_DOCKER_CADDYFILE_PATH env var which points to a file inside your CDP container which has your base Caddyfile. Any labels are applied on top of that base file.

sowinski commented 3 months ago

Okay thank you.

So this is also a recommended approach, even if I don't use docker swarm? Or would you still recommend to add this into a docker-compose as labels?

EDIT: And where would you place the config in the container?

francislavoie commented 3 months ago

Yes, it's what you should do. CDP supports both Swarm and non-Swarm Docker Compose.

And where would you place the config in the container?

Up to you. You could put it at /etc/caddy/Caddyfile which is the standard place for config (when not running in CDP mode)

sowinski commented 3 months ago

This works fine!

Is it possible to reload changes in the Caddyfile without restarting the container?