Now that HTTP/2 is a published standard (RFC 7540) and Jetty-9.3.0 has been released with HTTP/2.0, It’s time to start running this new protocol in your deployments. So let’s look at how you can run HTTP/2 on Google Compute Engine!

Selecting an Google Compute Image

The main requirement of a image to use is that it can run Java-8, which is pretty much any recent image and I’ve used the ubuntu-1504-vivid-v20150616a stock image provided by Google. Provision an image of this following googles documentation, then login to that image with SSH.

Installing Jetty

Jetty 9.3 is not currently available as deb, so it is simplest to download and install directly it in /opt:

You can now make a base directory to configure a jetty instance:

This enables a HTTP connector on port 8080 and a HTTPS connector on port 8443.  To access remotely on the standard ports, you need to add some redirections:

These iptables commands should be put into /etc/rc.local (or similar) to persist over restarts of the virtual machine.

Enabling HTTP/2

Unfortunately the normal steps to enable HTTP/2 on jetty will fail on Google computer engine with the following error:

This is because the Google image is not using a standard release of java, but rather an internally modified one. Because HTTP/2 requires ALPN support to be added to the boot path of the JVM, the jetty distribution is unable to do this by default for this JVM.  However, it is a trivial matter to make a module for the internal JVM, in the demo directory:

The normal command to enable HTTP/2 can now be run and the server started:

The server is now running and you can point your browser to the external IP address. If you use a https URL and your browser supports HTTP/2, then you will now be speaking HTTP/2 to Google Compute Engine!

HTTP/2 on Google Compute Engine with Jetty

Leave a Reply

Your email address will not be published. Required fields are marked *