Hey,
Following this thread : HeadersRegexp not working in Ingress
Wondering if this is valid for Gateway API also ?
Thanks in advance.
Hey,
Following this thread : HeadersRegexp not working in Ingress
Wondering if this is valid for Gateway API also ?
Thanks in advance.
Header regex matching is supported in Traefik's Gateway API implementation, but it works differently than the HeadersRegexp middleware approach used with IngressRoute.
With HTTPRoute (Gateway API), the native way to match on header values using a regex is via the headers match type in your HTTPRoute spec:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
spec:
rules:
- matches:
- headers:
- name: X-Your-Header
type: RegularExpression
value: "^prefix-.*"
The key is type: RegularExpression on the header match entry. This is part of the Gateway API spec itself, not a Traefik-specific extension, and Traefik v3 honours it.
This is distinct from the HeadersRegexp middleware which rewrites or manipulates headers. For routing based on header regex patterns, use the HTTPRoute approach above. For transforming header values, attach a Middleware via annotation or TraefikService.
The related issue about HeadersRegexp not working in Ingress was specifically about the old Ingress resource (not IngressRoute CRD and not HTTPRoute). In that context, middleware configuration via annotation had parsing quirks. With HTTPRoute that is not a concern since the regex is a first-class field in the spec.