In my current traefik configuration I have several services defined on consul and a couple of routers defined using files. The idea is simple, I do some URL matching on routers, and send traffic to any of my services on consulCatalog.
Some of my router rules overlap, so a given URL can match on several routers. Let's say that I need to route traffic from
app.example.com to one specific service, and that I also have a
*.example.com that needs to be handled in another.
If you rely, in such a case, on automatic priorities, odds are you won't get that functionality. Either way, there is this
priority field in routers that comes in handy. This works well unless you have a faulty service.
Suppose that the service that handles
app.example.com is down. In such a case, traefik takes it off the url processing and the request ends up in that used for
*.example.com. That could be desirable in most of the case but not in mine. I would like this request to fail, so I can act on the failure in other layers.
Currently there is no way to achieve this behavior in traefik, one could try several things.
One would be making rules not to overlap, but afaik you cannot negate a part of the rule, nor you can write in Go regexp such behavior, so there is no way to say
*.example.com but app.example.com. If there is a way of saying this I would like to know.
Another approach would be adding a new router with same rules but with a lower priority and then send it to a service that create crafted HTTP responses with the status I want. This is approach is ugly and way too complex for this use case.
And now my question.
Is there a way I could make traefik fail when the service associated with a matching router is down, a kind of a short-cirtuit evaluation?
Best regards, Jose Fernandez