I am using traefik v2.3.5 with docker swarm.
Here is my provider:
[providers]
[providers.docker]
watch = true
swarmMode = true
exposedbydefault = false
And this is my app service:
services:
app-backend:
networks:
- local-overlay
ports:
- "8082:8082"
deploy:
mode: global
labels:
- "traefik.enable=true"
- "traefik.http.routers.app.rule=PathPrefix(`/test`)"
- "traefik.http.routers.app.entrypoints=app"
#
- "traefik.http.services.app.loadbalancer.server.port=8082"
- "traefik.http.services.app.loadbalancer.healthcheck.path=/hc"
- "traefik.http.services.app.loadbalancer.healthcheck.interval=2s"
- "traefik.http.services.app.loadbalancer.healthcheck.timeout=1s"
I get this from log:
{"level":"warning","msg":"Health check still failing. Backend: \"app@docker\" URL: \"http://10.0.0.48:8082\" Reason: HTTP request failed: Get \"http://10.0.0.48:8082/hc\": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)","time":"2021-05-04T21:56:35Z"}
But when I remove the ports, not expose the 8082, everything works: