Enabling HTTP/2 on Apache 2.4 on Debian or Ubuntu

Apache 2.4.17 ships with mod_http2. Available in Debian 9 (stretch) and Ubuntu 16.04 (Xenial Xerus) (see comments) Ubuntu 16.10 (Yakkety Yak), it brings HTTP/2 support to one of the Internet’s popular Web servers. Assuming you’ve already configured a SSL/TLS Website, this quick tutorial will show you how to quickly enable HTTP/2.

Based on mod_h2, the module is still very experimental. It should be enabled manually, on a site-by-site basis, via the Protocols directive. The module’s defaults otherwise don’t need to be changed.

First, enable the module:

sudo a2enmod http2

In the <VirtualHost> stanzas for your Website served over TLS in your Apache configuration, add the Protocols directive:

<VirtualHost *:443>
  ServerName example.com

  Protocols h2 http/1.1

  # Other configuration stuff here…

Restart Apache:

sudo service apache2 restart

If you’ve curl 7.34.0 or later, you can test whether HTTP/2 is working by running:

curl -k -v --http2 https://example.com/

and look for mentions of “http2”.

While you’re fiddling with your Web server configuration, consider updating your SSL settings with Mozilla’s great SSL configuration generator.


Comments powered by Disqus