0

I would like to route traffic on HTTP Headers with Traefik. In case there is no matching rules, I need to route to another service or return a custom status code (426). Is it possible to configure default case for rules ?

apiVersion: traefik.containo.us/v1alpha1 
kind: IngressRoute 
metadata: 
  name: headers 
spec: 
  entrypoints: 
    - web 
    - websecure 
  routes: 
    - match: Headers(`X-ROUTE`,`Apache`) 
      kind: Rule 
      services: 
        - name: apache 
          port: 80 
    - match: Headers(`X-ROUTE`,`nginx`) 
      kind: Rule 
      services: 
        - name: nginx 
          port: 80
    - else ??
Arzhr
  • 435
  • 8
  • 22

1 Answers1

0

You can add this case to match anything with the lowest priority which is 1.

- match: HostRegexp(`{catchall:.*}`)
humbaba
  • 318
  • 2
  • 10
  • Could the service return a status code instead directly? – Arzhr Feb 20 '20 at 17:03
  • Afaik, there is no such option :( Even in case of errors (with errors middleware) you need to have a service to serve those error pages. – humbaba Feb 20 '20 at 17:21