Help Needed Defining Traefik Routing Rule in Kubernetes Ingress Annotation (Traefik 1.7.34)

Hi!

I'm using Traefik version 1.7.34 in my Kubernetes cluster and I'm struggling to define a routing rule using annotations within an Ingress resource.

I need to specify the following routing rule:

Rule: (HeadersRegexp(`Authorization`, `.*`) || Method(`OPTIONS`))

Could someone provide guidance or an example of how to properly format this rule with the traefik.ingress.kubernetes.io annotation field in my Ingress resource YAML?

Thx!

Traefik v1.7 was released in 2018 and official support ended 2021. You should just not use such an old version if you care about your site and network security.

@jbm were you able to get this working for a Traefik2x ingress controller?

Did you check the doc about router rule?

@bluepuma77 good question and thanks a bunch for the follow-up! Yep, that's great documentation and this is what I am attempting to do within my two routes I define in my IngressRoute:

metadata:
  name: keycloak-https
spec:
  tls:
    secretName: keycloak-tls
    options:
      name: keycloak-tls
      namespace: keycloak
  entryPoints:
    - websecure
  routes:
    - match: (PathPrefix(`/`) && !HeadersRegex(`X-Keycloak-Internal-Request`, `.*))
      kind: Rule
      services:
        - name: keycloak
          port: 8080
      middlewares:
        - name: "keycloak-strip-middleware"
          namespace: keycloak
        - name: "tls-client-cert"
          namespace: keycloak
        - name: "headerdump"
          namespace: keycloak
    - match: (PathPrefix(`/`) && Headers(`X-Keycloak-Internal-Request`, `true`))
      kind: Rule
      services:
        - name: keycloak
          port: 8080
      middlewares:
        - name: "keycloak-strip-middleware"
          namespace: keycloak
        - name: "headerdump"
          namespace: keycloak

It appears that both of these rules are ignored, but it's very possible I am doing something wrong. I am attempting to route requests on a redirect to the first route if the X-Keycloak-Internal-Request header is missing. In my testing all requests go to that first one, irrespective of whether the header is written or not.

Now, importantly, this week I discovered that the headers written on direct by the keycloakopenid plugin are not preserved on the two redirects embedded in their design when keycloakopenid is deployed behind a Traefik ingress controller in my K3S kubernetes cluster. So...I think that's the issue as opposed to anything related to the Headers and HeadersRegexp.

Consequently, it appears the key, core question is