Search code examples
httpssljettykuberneteshttp2

HTTP2 from the browser with early SSL termination


I want to set up my web page to make HTTP2 requests to a Jetty API server. I read that browsers will only use the "h2" protocol, that is, HTTP2 with TLS. However, my setup has a kubernetes ingress performing SSL termination, and proxying a cleartext request back to the Jetty server. The dilemma is that I don't think I want to negotiate an "h2" connection using Jetty, because that would require an SSL context on that server.

My question is, will this setup allow a browser to perform HTTP2 requests? If so, what do I need to enable on the Jetty server in order to properly serve HTTP2 requests?


Solution

  • You can configure Jetty to serve clear-text HTTP/2 (also known as h2c), so that your setup will be:

    browser -- h2 --> kubernetes tls termination -- h2c --> Jetty

    In order to setup Jetty with clear-text HTTP/2, you just need to enable the http2c module if you are using Jetty as a standalone server, see http://www.eclipse.org/jetty/documentation/current/http2-enabling.html.

    Alternatively, if you're using Jetty embedded you can look at this example.