TraefikRelay lets homelab users link Traefik instances on different hosts to a main, public-facing Traefik instance without using Docker Swarm or publishing ports.
TraefikRelay connects multiple Traefik instances by:
- Using Traefik's API on local instances to discover registered routes
- Publishing these routes to Redis, which the main Traefik instance reads as a provider
- Mapping entry points between instances to maintain proper routing
This approach lets you expose services from multiple hosts through a single public-facing Traefik instance, while keeping your internal network secure.
- A main Traefik instance configured with Redis provider
- One or more local Traefik instances with API access enabled
- Redis server accessible by both TraefikRelay and the main Traefik instance
docker pull ghcr.io/hhftechnology/traefik-relay:latest# Clone the repository
git clone https://github.com/hhftechnology/traefik-relay.git
cd traefik-relay
# Build the binary
go build -o traefik-relay ./cmd/traefik-relay
# Run the application
./traefik-relay --config=/path/to/config.ymlConfigure your main Traefik instance to use the Redis provider in traefik.yml:
providers:
redis:
endpoints:
- "redis:6379" # Change if Redis is not available on localhostHTTPS should be configured on this instance.
Enable API access in your local Traefik instances' traefik.yml:
api:
insecure: true # Only use within your local networkFor local instances accessible from the internet, enable API with Basic Auth instead:
api:
dashboard: trueAnd add a router with authentication middleware.
Create a config.yml file:
# Global settings
runEvery: 60 # Check for changes every 60 seconds
forwardMiddlewares: true
forwardServices: true
# Servers configuration
servers:
- name: "compute-1"
apiAddress: http://192.168.0.10:8080
destinationAddress: http://192.168.0.10
entryPoints:
web: web
web-secure: webREDIS_URL: Redis connection string (default:redis:6379)CONFIG_PATH: Path to config file (default:/config.yml)RUN_EVERY: Polling interval in seconds (default:60)
version: "3"
networks:
default:
name: "web"
services:
traefik:
image: traefik:latest
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik.yml:/traefik.yml:ro
- ./certs/acme.json:/acme.json
traefik-relay:
image: ghcr.io/hhftechnology/traefik-relay:latest
volumes:
- /root/config.yml:/etc/traefik-relay/config.yml
environment:
REDIS_URL: "redis:6379"
RUN_EVERY: 20
ENABLE_API: "true"
API_PORT: 8080
CONFIG_PATH: /etc/traefik-relay/config.yml
redis:
image: redis:alpine| Option | Description | Default |
|---|---|---|
name |
Unique name for the server | (required) |
apiAddress |
URL of the Traefik API (can include Basic Auth) | (required) |
apiHost |
Custom host header for API requests | (empty) |
destinationAddress |
URL where traffic should be directed | (required) |
entryPoints |
Mapping of main to local entrypoints | {"http": "http"} |
forwardMiddlewares |
Whether to forward middleware references | (global setting) |
forwardServices |
Whether to forward service references | (global setting) |
The entryPoints mapping works as follows:
- Left side: entrypoints on your main Traefik instance
- Right side: entrypoints on the local instance
Example:
entryPoints:
web: local-http # Map main 'web' to local 'local-http'
web-secure: local-http # Map main 'web-secure' to local 'local-http'TraefikRelay can identify if your internal router references a service not defined in the internal Traefik instance. For example:
services:
whoami:
labels:
traefik.http.routers.whoami-auth.service: "authentik@file"It will look for the authentik@file service in the main instance.
TraefikRelay can forward middleware usage from internal instances to the main instance. This is enabled by the forwardMiddlewares property in the configuration.
This means that middleware dependencies from local routers will be brought to the main instance, which will be responsible for finding them.
- Only use
insecure: truefor API access within your local network - For publicly accessible instances, always use proper authentication
- Consider using Docker networks to isolate containers
MIT License - See LICENSE file for details.