How to match an exact path but also a path prefix in the same traefik ingress

4/16/2019

I have a service that need to receive any request made on

  • / (exact match)
  • /aaa (path prefix)

Other paths will be sent to a different service.

Using traefik.frontend.rule.type: PathPrefix would work for the the second rule only and traefik.frontend.rule.type: Path for the first one only.

What is the recommended way to achieve this? Two distinct ingresses?

-- ITChap
kubernetes
traefik
traefik-ingress

1 Answer

4/16/2019

There are two options: As you suggested yourself, you can use two ingress objects. traefik will merge the definitions accordingly. For the Simple "/" route I assume that you want to do something like a redirect or load a browser client. You can use this annotation

traefik.ingress.kubernetes.io/app-root: "/aaa/index.html"

to redirect from the "/" route to a route that matches your pathprefixstrip.

-- Thomas
Source: StackOverflow