I’m using Traefik with only one Docker instance on a host. All is OK, ports 80 and 443 are redirected to the Docker host, certificates from Let’s Encrypt are fine, services are working, no problem.
I would like to add a new Docker instance to another host on the same network and use it with my existing Traefik (using the same domain). Is it possible to use Traefik like that and how to do it ? Or do I need to create a second Traefik instance ? But I can’t use 80 and 443 ports to get Let’s Encrypt certificates so how can I do ?
Just connect the second host with the first one via wireguard tunnel for example. Then just add wireguard IP of host2 to traefik on host1 + port . you can just install docker on host2.
Nothing would change in how Traefik uses letsencrypt or how it does certs. Traffix still comes in on 443 and traefik routes it to host2 via wireguard tunnel.
Using dynamic configs in Traefik is a keypoint then.
This is of course a heavy simplification. Just to give you an idea. Not a tutorial.
When they are in the same LAN. I guess at your home. Then just use the LAN ip of your host2 and add it to traefik with the external port of whatever docker container you use on host2.
Keypoints are dynamic-configs and file-provider in Traefik.
Traefik uses routers to determine the target service by Host/path of request. Targets can be auto-configured via Docker labels, then they usually use their own internal Docker IP. Or you use dynamic config loadbalancer.server.url to set an external target with IP or host (doc).
Note that in newer Traefik v3 you can now configure loadbalancer.server.url via labels with a different target than the container itself, so you don’t need a dynamic config file.