Languages
[Edit]
EN

apache2 - http2 / h2 protocol configuration

9 points
Created by:
AnnLen
9210

In this short article we would like show how to configure http2 protocol (called h2 over TSL) for Apache 2.4 server.

Read all sectons to know how to enable http2 / h2 protocol.

1. Software

During configuration following software were used (treat it only as recommendation):

  1. Windows 10,
  2. Apache 2.4.39 installed as WampServer x64 (download link here),
  3. PHP 7.3.5 (is installed automatically with WampServer, we need to select it with context menu only).
Switching to PHP 7.3.5 in WampServer
Switching to PHP 7.3.5 in WampServer

2. HTTPS configuration

http2 / h2 protocol requires HTTPS protocol. Go to this article to see how to configure it.

3. Enabling Apache 2.4 modules

In this case we need to enable only one module: http2_module.

We can do it in 2 ways:

  • from context menu: Apache -> Apache modules -> http2_module
  • from configuration file c:\wamp64\bin\apache\apache2.4.39\conf\httpd.conf by uncommenting following line:
    LoadModule http2_module modules/mod_http2.so

4. Setting Apache 2.4 configurations

It is necessary to add inside VirtualHost which provides HTTPS connection only one line that enables http2 / h2 protocol:

Protocols h2 http/1.1

In my case c:\wamp64\bin\apache\apache2.4.39\conf\extra\httpd-vhosts.conf file as last configuration contains following VirtualHost:

<VirtualHost *:443>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  SSLEngine on
  SSLCertificateKeyFile "${INSTALL_DIR}/bin/apache/apache2.4.39/conf/cert/localhost.key"
  SSLCertificateFile "${INSTALL_DIR}/bin/apache/apache2.4.39/conf/cert/localhost.crt"
  SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
  Protocols h2 http/1.1
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>

Note: you can use Protocols h2 h2c http/1.1 if you want to enable HTTP/2 over TCP too - read more here.

5. Server restart

Most simple is to click Restart All Services item in WampServer context menu located in Windows try bar.

6. Verify HTTP2 / h2 connection

Use Google Chrome DevTools to check if http2 is enabled.

Note: to see how to verify http2 with openssl read this article.

apache 2 with enabled http2 / h2 protocol
apache 2 with enabled http2 / h2 protocol

Note: use right mouse button to display Protocol column. 

Native Advertising
50 000 ad impressions - 449$
ūüöÄ
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

‚̧ԳŹūüíĽ ūüôā

Join