#12795·traefik

HTTPRoute with specific hostname loses to catch-all HTTPRoute (no hostnames)

Author: DoublefullCreated Mar 11, 2026Updated Sep 21, 2026
Labelskind/bug/possiblecontributor/waiting-for-feedbackarea/provider/k8s/gatewayapi

Welcome!

  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've searched similar issues on the Traefik community forum and didn't find any.

What did you do?

Context

Using Kubernetes Gateway API with Traefik as the Gateway controller.

I need a routing setup where:

  • a catch-all HTTPRoute (no hostnames) routes to a default backend
  • another HTTPRoute with a specific hostname routes to a different backend

According to Gateway API specification, the route with the most specific hostname match should take precedence.

However, the catch-all route always wins.

Steps to reproduce

Gateway

yaml
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: traefik-gateway
spec:
  gatewayClassName: traefik
  listeners:
    - name: web
      port: 80
      protocol: HTTP

Catch-all HTTPRoute

yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: catch-all
spec:
  parentRefs:
    - name: traefik-gateway
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: backend1
          port: 80

Hostname HTTPRoute

yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: hostname-route
spec:
  parentRefs:
    - name: traefik-gateway
  hostnames:
    - api.example.com
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: backend2
          port: 80

Test request

bash
curl -H "Host: api.example.com" http://<gateway-ip>/

Expected result:

backend2

What did you see instead?

Requests with:

*Host: api.example.com*

are routed to the catch-all route instead of the hostname route.

Actual result:

backend1

Additional observations:

  • adding header match for Host does not change behaviour
  • both routes use the same PathPrefix /
  • the catch-all route consistently wins

This seems to contradict Gateway API route precedence rules where a more specific hostname match should win. It seems that the catch-all route and hostname route are treated with equal priority and the older route wins.

What version of Traefik are you using?

traefik version
Version:      3.6.6
Codename:     ramequin
Go version:   go1.24.11
Built:        2025-12-29T15:47:44Z
OS/Arch:      linux/amd64

What is your environment & configuration?

Environment:

  • Kubernetes cluster
  • Traefik deployed via Helm
  • Gateway API provider enabled
  • HTTPRoute resources used for routing

Traefik config

yaml
deployment:
  kind: DaemonSet

hostNetwork: true 

updateStrategy:
  type: RollingUpdate
  rollingUpdate:
    maxUnavailable: 1
    maxSurge: 0

ports:
  traefik:
    port: 8001
    expose:
      default: false
  web:
    port: 80
    hostPort: 80
    forwardedHeaders:
      insecure: false
    middlewares:
      - "traefik-global-limit@kubernetescrd" 
  websecure:
    port: 443
    hostPort: 443
    forwardedHeaders:
    middlewares:
      - "traefik-global-limit@kubernetescrd" 
  metrics:
    port: 9200

service:
  enabled: true
  type: ClusterIP


ingressClass:
  enabled: false

providers:
  kubernetesGateway:
    enabled: true
  kubernetesIngress:
    enabled: false
  kubernetesCRD:
    enabled: true

gateway:
  enabled: true
  listeners:
    web:
      port: 80
      protocol: HTTP
      namespacePolicy:
        from: All
    websecure:
      port: 443
      protocol: HTTPS
      namespacePolicy:
        from: All
      mode: Terminate
      certificateRefs:
        - name: jaeger-tls

gatewayClass:
  enabled: true

logs:
  general:
    level: INFO
  access:
    enabled: true
    format: "common"
    addInternals: true

metrics:
  addInternals: true
  prometheus:
    enabled: true
    service:
      enabled: true
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "9200"
        prometheus.io/path: "/metrics"
      labels:
        app: traefik
        release: traefik

extraObjects:
  - apiVersion: traefik.io/v1alpha1
    kind: Middleware
    metadata:
      name: global-limit
    spec:
      buffering:
        maxRequestBodyBytes: 209715200 #200 MB

If applicable, please paste the log output in DEBUG level

No response