HTTPURLRewriteFilter hostname type: Backend does not rewrite host name to Kubernetes DNS (auto_host_rewrite ineffective for K8s Services)
#7984 aperta il 19 gen 2026
Metriche repository
- Star
- (2871 star)
- Metriche merge PR
- (Metriche PR in attesa)
Descrizione
** 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
- The implementation configures
auto_host_rewrite: trueon the generated Envoy route, but Kubernetes Service backends are configured asEDSclusters (endpoints = static IPs). - According to Envoy docs,
auto_host_rewriteonly works with STRICT_DNS or LOGICAL_DNS clusters. - For k8s Services, Envoy Gateway uses EDS clusters with IP addresses (not DNS), so auto host rewrite is ineffective.
- 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
- Create an HTTPRoute with a backendRef to a Kubernetes Service
- Apply an HTTPRouteFilter extension with hostname rewrite
{ type: Backend } - Send a request through Envoy Gateway
- 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.