apache2 - http2 / h2 protocol configuration
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, the following software were used (treat it only as recommendation):
- Windows 10,
- Apache 2.4.39 installed as WampServer x64 (download link here),
- PHP 7.3.5 (is installed automatically with WampServer, we need to select it with context menu only).
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.
Note: use right mouse button to display Protocol column.Â