2
votes

Traefik Version: 1.6.4

My company uses Docker Swarm to present applications as services, using Traefik for routing. All has been working fine so far, but we're having trouble implementing backend health checks in Traefik.

All of our applications expose a health check, which works fine and returns 200 via a simple curl or hitting it in a web browser. We've applied Docker labels to our swarm services to reflect these health checks. As an example:

traefik.backend.healthcheck.path=/health
traefik.backend.healthcheck.interval=30s

The Traefik service logs report the following:

{"level":"warning","msg":"Health check still failing. Backend: \"backend-for-my-app\" URL: \"https://10.0.0.x:8080\" Reason: received non-200 status code: 406","time":"2018-07-10T19:41:25Z"}

Within the app containers we have Apache running with ModSecurity. ModSecurity is blocking the request because the host header is a numeric IP address. I shelled into the Traefik container and did a couple curls against the app container to test:

curl -k https://10.0.0.x:8080/health <-- ModSecurity blocks this, returns a 406
curl -k -H "Host: myapp.company.com" https://10.0.0.x:8080/health <-- works fine, returns a 200

TLDR: I need a way to set a host header for the Traefik backend health check. In Traefik docs, I don't see a way of doing this. Has anyone run into this issue, and/or know of a solution?

1

1 Answers

0
votes

In Traefik 1.7, there is an option to add custom headers, and define a host header for the backend healthcheck:

https://docs.traefik.io/v1.7/configuration/backends/docker/

For example traefik.backend.healthcheck.hostname=foobar.com

Please note that 1.7 is still in RC, but you can test it out to see if it resolves your issue. If you need this in production, you will have to wait for 1.7 to reach stable status.