Health check hostname not working?

I'm using version 2.2.8 of traefik with Docker. I have these labels for my docker service:

labels: traefik 3000 /health 80 http 15s 4s
      traefik.http.routers.crimson_node.service: crimson_node
      traefik.http.routers.crimson_node.entrypoints: websecure
      traefik.http.routers.crimson_node.rule: Host(`${NEXT_PUBLIC_SITE_DOMAIN}`)
      traefik.http.routers.crimson_node.tls: true
      traefik.http.routers.crimson_node.priority: 2
      traefik.http.routers.crimson_node.middlewares: crimson_node_compress@docker
      traefik.http.middlewares.crimson_node_compress.compress: true

When I look at the logs for traefik I see:

 Health check still failing. Backend: "crimson_node@docker" URL: "" Reason: HTTP request failed: Get "": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

It's not taking the hostname into account at all? No matter what hostname I put it still uses the container IP address instead of the hostname I provide. Am I using it wrong?

Can you explain what you are trying to achieve?

I have a custom health check I want to perform at a specific my Instead of using the container ip address. I can't control the endpoints of the container that has the health check because it's a third party image. I would like to have a container I use specifically for health checking that all my services can use to query to check health status.

And when that health check passes/fails what do you expect traefik to do?

This healthcheck in traefik was designed with a specific purpose to exclude any services behind the load balancer that fail the healthcheck from the rotation. It is not designed to bring the whole load balncer down if some third party service fails a health check.

So if this is what you are expecting to happen, that's not how this part of traefik works.

I guess I'm confused. What is the purpose of the hostname parameter on the health check? Is that not suppose to replace the hostname the health check uses? What is it suppose to do? I don't want it to take down the whole load balance. Could you explain what setting the hostname actually does if not using it to make a request?

What is the purpose of the hostname parameter on the health check? Is that not suppose to replace the hostname the health check uses? What is it suppose to do?

Yep, this is not documented correctly, I just submitted a PR to fix this.

It can happen, that you host another reverse proxy or a web server behind traefik (e.g. nginx) which further routes http request based on the host header. Traefik will get service ip from docker discovery, and if the host header is not set correctly, that second proxy or web server would not know where to route this healthcheck. This option is to provide this information.

Does this make sense?

Oh I see, so it has nothing to do with the hostname used to query the health check like port and scheme do. It's just specifically adding a Host header to the request?

Correct. I think traefik assumes that health check of a certain node always resides on that said node.

Another thing to keep in mind, that docker is not the only configuration discovery provider traefik has, and mostly, options has to work similarly between different providers. In some cases it creates certain wrinkles, because of the difference in the providers.

If you think about it when doing a health check there has to be a piece of information that differentiate one node from another, that is the health check is only meaningful if we can tell which node needs to be take out of / into rotation based on the health check result. So the actual node location is this differentiation.

Got it. Thanks for the info!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.