How to Configure HTTP/2 in Apache on CentOS 8
The HTTP/2 protocol was created as a more advanced version of HTTP. It allows you to speed up the site and reduce the load on the web server and communication channel. All this leads to a reduction in costs and even an increase in the site's position in search engines. In this tutorial, we will configure HTTP/2 protocol in Apache web server on CentOS 8. To get started, you will need an
SSL certificate installed on Apache. You can use this tutorial how to Setup Let’s Encrypt SSL on Apache. Most browsers only work with HTTP/2 over HTTPS.
In the Serverspace you can create a server with already installed app "Apache".
Preparing the system
First, you need the latest version of Apache. Therefore, you need to update the packages in the system.
dnf upgrade
On CentOS/RHEL 8 systems mod_http2 is installed with Apache. To make sure that it is in the system, or install it if not:
dnf install mod_http2
Apache configuration for HTTP/2
Make sure that the HTTP/2 module is enabled in Apache.
cat /etc/httpd/conf.modules.d/10-h2.conf
Output:
LoadModule http2_module modules/mod_http2.so
Open the configuration file for your virtual host and find the section VirtualHost *:443
nano /etc/httpd/conf.d/domain-name.com.conf
It may also be in the domain-name.com-le-ssl.conf file. Add the Protocols parameter there.
<virtualhost :443>
Protocols h2 http/1.1
...</virtualhost>
Save and close the file, and then restart Apache.
systemctl restart httpd
Check if HTTP/2 works
You can check it this way:
curl -I https://domain-name.com
Output:
HTTP/2 200
...