Hello: I haven’t used caddy yet but have a few questions to get me started.
How does caddy handle reverse proxy for docker containers that are not on the same host/server as caddy itself? Assume the servers are not in a swarm and are standalone. How does it handle service discovery in this case ? I am finding very little information on how to do this.
There is plenty of info on reverse proxy setups but most of them assume the containers are all on the same server. I have come across one or two mentions of using consul for service discovery across servers but was over my head for a simple home network. Will appreciate some guidance .
Docker itself runs a DNS resolver that resolves service names to IP addresses in the Docker network.
If you use the Docker service names when proxying in Caddy, then Caddy uses DNS to lookup the IP address, which will be resolved by Docker’s resolver, and Docker’s networking stack does the job of routing connections to that IP address over to your other machine via swarm.
Basically, this is all Docker stuff, it has nothing to do with Caddy. Docker stuff is all invisible to Caddy.
You could use GitHub - lucaslorentz/caddy-docker-proxy: Caddy as a reverse proxy for Docker which is a plugin which allows you to use Docker labels to configure Caddy; the plugin will connect to Docker’s API to find out which containers are in the same network, read labels off them, then reload Caddy with a newly generated config. This lets you dynamically start services and they’ll be picked up as long as they’re in the same network. But if you’re just running a single “app”, this would be overkill, probably.
This topic was automatically closed after 30 days. New replies are no longer allowed.