I've configured a "ErrorPage" middleware for return custom pages when an error occured on my services.
My middleware use a service named "service-errors", this service has one server "http://error.my-domain.com"
My server "error.my-domain.com" is an independant Apache webserver with a VirtualHost configured for this domain. He work correctly without Traefik.
My use case :
I've multiple servers on my service
healthcheck is enabled on my service
when all servers are down, healthcheck return HTTP 503
when i've a 503 error, I want capture this with ErrorPage middleware
What did you expect to see?
When all servers are down, I want see my custom error page from error.my-domain.com.
What did you see instead?
I see default Apache page "It work !"
After analyze with a tcpdump, in HTTP header, I see this : "Host 0.0.0.0" instead of "Host error.my-domain.com".
Output of traefik version: (What version of Traefik are you using?)
# traefik version
Version: 2.2.8
Codename: chevrotin
Go version: go1.14.6
Built: 2020-07-28T15:46:03Z
OS/Arch: linux/amd64
@ldez Reading the code, it looks like this is a legitimate issue to me, that is it looks like this host header might indeed come form that backendURL linked above. Would you mind having a look and explaining us where we went wrong?
The error pages don't handle the case when all servers are down: the middleware don't handle the 404 from Traefik.
To handle that you have to create a catch-all router with a low priority.
@ldez Can you explain why do you feel it is? The service for error page can point to an arbitrary back end, which includes external. An external back end very well might require a particular host header, like in the OP example. It seems like a valid scenario to me. (Just ignore the all servers are down part for the sake of this clarification).
Indeed, I think that example "all servers are down" is bad. The problem is same if i can use error pages for classic use case with my error pages hosted on an external webserver.
By default, a service is queried with the "Host" header requested by the user OR with the domain name of the server (if "passHostHeader" option has the value "false")
I don't understand why this middleware would need special behavior with "Host 0.0.0.0".