envoyproxy/gateway

HTTPURLRewriteFilter hostname type: Backend does not rewrite host name to Kubernetes DNS (auto_host_rewrite ineffective for K8s Services)

Open

#7,984 opened on 2026年1月19日

GitHub で見る
 (4 comments) (0 reactions) (0 assignees)Go (802 forks)auto 404
area/translatorhelp wantedkind/enhancement

Repository metrics

Stars
 (2,871 stars)
PR merge metrics
 (PR metrics pending)

説明

** full disclosure - this issue is created with help of Github Copilot **

Description

When using the HTTPURLRewriteFilter extension with hostname set to { type: Backend }, the host name is not rewritten to the expected Kubernetes service DNS (e.g. backend.default.svc.cluster.local). Instead, the original host header is forwarded to the backend.

Expected behavior: Using:

apiVersion: gateway.envoyproxy.io/v1alpha1
kind: HTTPRouteFilter
spec:
  urlRewrite: 
    hostname:
      type: Backend

to rewrite the Host header to the cluster DNS name of the backend Kubernetes service referenced in the HTTPRoute backendRefs.

Actual behavior: The Host header is not rewritten, and backend application receives the original host header, not the expected service DNS.

Technical Analysis

  1. The implementation configures auto_host_rewrite: true on the generated Envoy route, but Kubernetes Service backends are configured as EDS clusters (endpoints = static IPs).
  2. According to Envoy docs, auto_host_rewrite only works with STRICT_DNS or LOGICAL_DNS clusters.
  3. For k8s Services, Envoy Gateway uses EDS clusters with IP addresses (not DNS), so auto host rewrite is ineffective.
  4. As a result, the Host header rewrite does not work as expected for Kubernetes Service backends, even though the extension's API implies it should.

Suggested Remediation

  • The translation logic could detect when hostname: { type: Backend } is configured, and instead of EDS/IP clusters for referenced Services, create STRICT_DNS clusters pointed at the service's Kubernetes DNS name (e.g. backend.default.svc.cluster.local).
  • Alternatively (less desirable), detect the case and explicitly set the DNS name as a literal host rewrite, or emit a warning if not supported for EDS clusters.

References

Repro steps

  1. Create an HTTPRoute with a backendRef to a Kubernetes Service
  2. Apply an HTTPRouteFilter extension with hostname rewrite { type: Backend }
  3. Send a request through Envoy Gateway
  4. Observe that the backend receives the original Host header, not the expected service DNS

Notes: This bug explains why host rewrite works for header and static literal modes, but not for Backend mode on Services. The root cause is the cluster type mismatch with what Envoy supports for auto host rewrite.

コントリビューターガイド