Skip to content

HttpListener: opt-in HTTP/2 prior knowledge (h2c) for cleartext gRPC #1911

Closed

Description

@Shine-neko

Context

HttpListener deliberately refuses HTTP/2 over cleartext: no Upgrade: h2c, and no prior-knowledge detection, so a client sending the PRI * HTTP/2.0 preface gets a 400 (see the doc comment on HttpListener in lib/src/http.rs). HTTP/2 from clients is only reachable through TLS ALPN.

Backends, on the other hand, can already be spoken to over h2c (Cluster.http2).

Use case

gRPC in cleartext with prior knowledge is common inside a cluster or a private network, where TLS is terminated elsewhere or not used. It is also what the Kubernetes Gateway API conformance suite uses for GRPCRoute: its gRPC client dials the Gateway with insecure credentials, i.e. h2c prior knowledge on the HTTP port. A proxy built on Sōzu (we hit this in Sōzune) cannot serve GRPCRoute there, nor pass the GATEWAY-GRPC conformance profile.

Proposal

An opt-in, per-listener setting on HttpListenerConfig (e.g. h2c_prior_knowledge: bool, default false): when on, a connection whose first bytes are the HTTP/2 connection preface is handled as an HTTP/2 frontend, as an ALPN h2 one is on HttpsListener. Anything else stays HTTP/1.x.

  • Prior knowledge only: Upgrade: h2c, which RFC 9113 deprecates, is not needed.
  • Off by default, so the current posture is unchanged for everyone who does not ask for it.
  • nginx (listen ... http2 without ssl) and Envoy (codec_type: AUTO / HTTP2 on a plaintext listener) both offer it as an explicit choice.

Would you be open to this? Happy to give more detail on the Gateway API side if useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions