HTTP/2 is the most recent version of the Hypertext Transfer Protocol (HTTP), and it is quicker, more secure, and more efficient than HTTP/1.1. If you run a website on an Apache2 or Nginx server, activating HTTP/2 can greatly enhance website performance. This article will walk you through the process of configuring HTTP/2 on an Apache2 or Nginx server.
The multiplexing feature allows the server to establish a single connection and send all the files to the client’s browser. Let’s start adding HTTP/2 support on NGINX webserver.
Adding HTTP/2 support to the Nginx server:
Step 1: Verify your Nginx version.
Make sure you have Nginx version 1.9.5 or later installed before activating HTTP/2. You may determine your Nginx version by performing the following command.
nginx -v
Step 2: Turn on SSL.
You must first enable SSL on your Nginx server before you can enable HTTP/2. If SSL is already enabled, you can skip this step. If not, proceed as follows:
Install the SSL module by running
sudo apt-get install nginx-extras.
Configure Nginx with SSL: Open the Nginx configuration file (/etc/nginx/nginx.conf), add the following lines:
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
Restart the Nginx server using sudo service nginx restart
Step 3: Turn on HTTP/2.
Add the following line to the Nginx configuration file (/etc/nginx/nginx.conf) to enable HTTP/2:
listen 443 ssl http2;
Note: If you already have ssl enabled in your nginx configuration, add “http2” just after “listen 443 ssl“; directive.
Restart the Nginx server.
After you’ve made the necessary modifications, restart the Nginx server using the following command:
sudo service nginx restart
Adding HTTP/2 support to an Apache2 server:
Step 1: Determine your Apache version.
Make sure you have Apache version 2.4.17 or later installed before enabling HTTP/2 on Apache2. Run the following command in the terminal to determine your Apache version:
apache2 -v
Step 2: Turn on SSL.
You must first enable SSL on your Apache2 server before you can enable HTTP/2. If SSL is already enabled, you can skip this step. If not, proceed as follows:
- Install the SSL module by running
sudo a2enmod ssl
.
- Restart the Apache server using
sudo service apache2 restart
Step 3: Turn on HTTP/2.
Add the following lines to the Apache configuration file (/etc/apache2/apache2.conf) to enable HTTP/2:
<IfModule http2_module>
Protocols h2 http/1.1
</IfModule>
Restart the Apache server.
After you’ve made the necessary modifications, restart the Apache server with the following command:
sudo restart service apache2
Enabling HTTP/2 on your Apache2 or Nginx server may greatly enhance website performance. You may easily implement HTTP/2 on your server and experience the benefits of quicker and more secure surfing by following the procedures outlined above.