Skip to content

Support IP based Host matching in HTTPRoute.spec.hostnames (IPv4 and IPv6) #4444

@alviss7

Description

@alviss7

What would you like to be added:

I would like to be able to route HTTP traffic based on IP addresses in HTTPRoute.spec.hostnames, for DNS over HTTPS (DoH) use cases, in a way that is consistent for both IPv4 and IPv6.

Today the Hostname type is documented as not allowing IPs, and validated with the regex:

^(\*\.)?[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$

However, this regex actually matches IPv4-like values such as 192.0.2.10, and at least one implementation (Envoy Gateway) correctly accepts and routes a HTTPRoute with:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: httproute-test
  namespace: httproute-test
spec:
  hostnames:
    - '192.0.2.10'
  parentRefs:
    - name: shared-gateway
      namespace: envoy-gateway
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: httpbin-a
          port: 8080

and successfully routes HTTP traffic where Host: 192.0.2.10.

I would like the spec to either:

  1. Explicitly support IP addresses (both IPv4 and IPv6) in HTTPRoute.spec.hostnames for valid use cases like DoH, with a clear validation model,
    or
  2. Explicitly clarify that IPs must not be allowed (including 192.0.2.10), and provide a standard, spec-compliant way to express this kind of routing (for example, a different field, route type, or documented pattern).

Why this is needed:

For DNS over HTTPS, some clients use an IP address as the endpoint, for example:

  • https://192.0.2.10/dns-query
  • https://[2001:db8::10]/dns-query

In these cases, the client sends an HTTP request with an IP in the Host header.

Today:

  • The spec says IPs are not allowed in Hostname, but the regex still matches IPv4 values like 192.0.2.10.
  • With Envoy Gateway, HTTPRoute.hostnames: ["192.0.2.10"] works correctly for IPv4.
  • There is no way to express the same behavior for IPv6, because IPv6 strings (e.g. 2001:db8::10 or [2001:db8::10]) cannot match the Hostname regex.

This leaves me in an ambiguous state:

  • For IPv4, I can rely on behavior that is effectively out of spec (the regex accepts the value and the implementation routes it).
  • For IPv6, I have no standard way to express the same need.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions