Hi I'm running Traefik 2.9.6 using docker-compose.
How do I add a remote/external (not hosted on the same docker host) service using labels/commands?
I tried to add the following labels to the traefik container but that didn't work
- "traefik.enable=true"
- "traefik.http.routers.test.rule=Host(`test.localhost`)"
- "traefik.http.routers.test.service=test"
- "traefik.http.services.test.loadbalancer.server.ip=192.168.10.15"
- "traefik.http.services.test.loadbalancer.server.port=5568"
When I start Traefik and look in the dashboard it dosen't seem to find the test service.
Would you mind sharing your full Traefik static and dynamic config, and docker-compose.yml if used?
You should probably use .url. Do you have provider.docker enabled to read the labels?
I don't have any other config excluding my command section.
traefik:
image: "traefik:${TRAEFIK_VERSION}"
container_name: "traefik"
restart: unless-stopped
read_only: true
mem_limit: 2G
cpus: 0.75
security_opt:
- no-new-privileges:true
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
# Logs
- --accesslog.filepath=/logs/access.log
- --accesslog.format=json
- --accesslog.fields.defaultMode=keep
- --accesslog.fields.headers.defaultMode=keep
- --log.filepath=/logs/traefik.log
#- --log.format=json
labels:
- "traefik.enable=true"
- "traefik.http.routers.test.rule=Host(`test.localhost`)"
- "traefik.http.routers.test.service=test"
- "traefik.http.services.test.loadbalancer.server.ip=192.168.10.15"
- "traefik.http.services.test.loadbalancer.server.port=5568"
environment:
- TZ=Europe/Stockholm
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- ./traefik/logs:/logs
Did you see my comment regarding .url? You should try
.loadbalancer.server.url=http://192.168.10.15
Update: Seems you can't use .loadbalancer.server.url in labels, so you need to create a dynamic config file with loadbalancer and load that file via provider.file in your static config.
Thanks that explains why it didn't even show up in the ui or the logs!