Summary
I've often seen Traefik cited as the best method for solving a problem I have, and I wanted to present my environment to the community in the hopes of checking if Traefik Proxy would provide the solution I need.
I have four physical servers each hosting multiple docker containers. Some of these services need to be aware of containers on other servers. Over the past year and a half I’ve tried different methods to achieve this:
- Default Bridge network
- Attachable Overlay network (without a Swarm)
- Moving everything possible to the Host network
- Considering a macvlan network
It was when I was researching the idea of a macvlan network that I found a reply to a thread on network best practices that suggested the use of Traefik - and I have previously come across Traefik examples that seemed like they would fit my needs.
Environment
I have four servers with a minimal Linux installation and the docker engine and compose plugin, installed the approved way.
-
OS Version/build
- Debian 11.5 bullseye (or Raspberry Pi OS equivalent)
-
App versions
- Docker version 23.0.0, build e92dd87
- Docker Compose version v2.15.1
For the four servers running Debian 11.5 headless, there is the following configuration:
-
Hardware
- 2 x Edge servers : Raspberry Pi 4b RAM 2GB SSD 120GB
- 1 x Services server : Intel NUC7CJYHN RAM 16GB SSD 500GB
- 1 x Security server : Intel NUC8i3BEH RAM 32GB SSD 250GB
-
Container Management
- Exclusive use of docker-compose.yml files for managing containers
- Configuration-as-code stored in private github repositories
- Server specific information held in .env.example files
- .env files created before container start
Topology
My two edge servers provide local manual redundancy. All servers run common logging services, along with specific services based on their role.
- Two edge servers running:
- Services server running:
- Security server running:
- Common services running across all four servers:
- Plus other containers, including Prometheus, InfluxDB, and MariaDB, but you get the idea here
Questions
-
Can an instance of Traefik Proxy on an Edge server manage and discover services on separate physical hosts? Is it simply a matter of adding a proxy docker socket connection for each host?
-
If this isn't possible, is Traefik still valid for local discovery, with an installation on each physical host, and all external calls managed by Nginx Proxy Manager?
-
If it is possible without autodiscovery - i.e. I'd have to manually add entries for each service via
http://[host]:[port]/
- then is this possible via TOML/YAML or docker-compose.yml configuration? -
If I host Traefik Proxy on my edge servers, is there a configuration that would enable them to cluster or be aware of each other?
-
I currently host 59 services across 4 hosts, 12 of which are exposed to the internet as subdomains on a URL. I do not want to expose all 59 to the internet, is there a way with Traefik Proxy to set some of them to an internal domain (for example, ending my TLD with .lan rather than .com or similar)? I would manage the internal domain using dnsmasq.d as part of Pi-Hole, if this is possible.
-
Can any of the containers run in
network_mode: host
or is it best practice for them all to be on a custom Bridge network? -
My domain is managed through Azure DNS Zones. I have subdomain CNAME records which point to [domain].duckdns.org which are then routed to my IP address. My router then forwards requests on ports 443 and 80 to Nginx Proxy Manager. These calls are then routed to the correct services by NPM. Will this configuration (Azure -> DuckDNS -> Router -> Traefik still work?
Thank you for reading this, and for any insights!