-
Notifications
You must be signed in to change notification settings - Fork 664
Description
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: 8080and successfully routes HTTP traffic where Host: 192.0.2.10.
I would like the spec to either:
- Explicitly support IP addresses (both IPv4 and IPv6) in
HTTPRoute.spec.hostnamesfor valid use cases like DoH, with a clear validation model,
or - 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-queryhttps://[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 like192.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::10or[2001:db8::10]) cannot match theHostnameregex.
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.