How to Enable HTTP/2 On a Server
HTTP/2 is a major advancement in web protocol technology, offering significant improvements in speed, efficiency, and security over HTTP/1.1. With features like multiplexing, header compression, and server push, HTTP/2 can significantly reduce web page load times and enhance the user experience.
In this blog, we’ll explain HTTP/2 and guide you through the process of enabling it on your server using common control panels like Plesk and cPanel. We’ll break down the steps, providing detailed instructions and important notes to ensure a smooth transition. Let’s get started!
What is HTTP/2?
HTTP/2 is a major revision of the HTTP network protocol, officially approved in 2015. Based on Google’s SPDY protocol, it is designed to improve the speed, efficiency, and security of data transfer between a client and server. HTTP/2 addresses many of the performance limitations of HTTP/1.1, which was standardized back in 1997.
HTTP/2 vs. HTTP/1.1
Connection Management
- HTTP/1.1: Uses a single connection per request-response pair, leading to inefficiencies and increased latency.
- HTTP/2: Utilizes a single connection for multiple streams, allowing multiple requests and responses to be sent simultaneously over one connection, reducing overhead and latency.
Header Compression
- HTTP/1.1: Headers are sent as plain text, which can become quite large and add significant overhead.
- HTTP/2: Implements header compression using the HPACK algorithm, reducing the size of headers and the amount of data that needs to be transferred.
Data Format
- HTTP/1.1: Uses a text-based format, which is less efficient and more prone to errors during parsing.
- HTTP/2: Adopts a binary format, which is more efficient for both transmission and parsing, reducing the likelihood of errors.
Server Push
- HTTP/1.1: The server can only respond to requests made by the client.
- HTTP/2: Introduces server push, allowing the server to send resources to the client proactively before they are requested, reducing load times for web pages by preloading critical resources.
The Need for HTTP/2
Growing Complexity of Web Content
Modern web pages often include numerous resources such as images, JavaScript files, CSS stylesheets, and more. HTTP/1.1 can lead to significant inefficiencies and delays due to the need for separate requests for each resource.
Performance Bottlenecks
HTTP/1.1’s request-response model can become a bottleneck, especially on mobile networks or in high-latency environments, slowing down page loads and frustrating users.
Enhanced Security Requirements
HTTP/2 requires the use of SSL/TLS, ensuring that data is encrypted during transmission, which enhances security and builds user trust.
Improved User Experience
Faster websites lead to higher user engagement, better search engine rankings, and increased conversions. HTTP/2’s features, such as multiplexing and server push, are key to achieving these performance gains.
Key Features and Benefits of HTTP/2
- Multiplexing: Multiple requests and responses can be sent simultaneously over a single connection.
- Header Compression: Reduces the overhead of HTTP headers, improving performance.
- Server Push: Allows servers to send resources to the client before they are requested.
- Binary Protocol: Unlike the text-based HTTP/1.1, HTTP/2 uses a binary format, which is more efficient to parse and less error-prone.
Enable HTTP/2 – Start Using HTTP/2
Before enabling HTTP/2, run a performance test on WebPageTest.org. Save the results – we’ll revisit them soon.
Plesk
- Log in to Plesk.
- Go to Tools & Settings > Updates and Upgrades to update Plesk and server packages.
- Verify that your server meets the requirements for HTTP/2 (Apache with nginx as a reverse proxy or Apache with mod_http2 module).
- Go to Tools & Settings > Apache Web Server and check the box to enable HTTP/2 support.
- Ensure nginx is configured to work with HTTP/2 if used as a reverse proxy, or ensure the mod_http2 module is enabled for Apache.
- Go to Websites & Domains > [select your domain] > SSL/TLS Certificates to install or verify a valid SSL certificate.
- Test HTTP/2 support using online tools like KeyCDN HTTP/2 Test or SSL Labs.
- Go to Tools & Settings > Services Management and restart Apache and nginx services.
Optional: Enabling HTTP/2 for Specific Domains
- Log in to Plesk.
- Go to Websites & Domains and select the domain.
- Click on Apache & nginx Settings.
- Enable Proxy mode, Smart static files processing, and HTTP/2 support.
- Click OK or Apply to save changes.
- Restart necessary services as described earlier.
cPanel
- Log in to WHM.
- Go to Home > cPanel > Upgrade to Latest Version to ensure cPanel is up to date.
- Go to Home > Software > Update Server Software and Home > Software > System Update to ensure all server packages are current.
- Navigate to Home > Software > EasyApache 4 and ensure EasyApache 4 is installed.
- In EasyApache 4, click Customize next to your current profile, go to the Apache Modules section, select the mod_http2 module, and click Provision.
- Go to Home > Service Configuration > Apache Configuration > Global Configuration and ensure the Protocols directive includes h2 and http/1.1.
- Go to Home > SSL/TLS > Manage SSL Hosts to install or verify valid SSL certificates for your domains.
- Go to Home > Restart Services > HTTP Server (Apache) and click Yes to restart Apache.
- Verify HTTP/2 support using online tools like KeyCDN HTTP/2 Test or SSL Labs.
Optional: Enabling HTTP/2 for Specific Domains
- Log in to cPanel.
- Go to Security > SSL/TLS and ensure a valid SSL certificate is installed for your domain.
- Verify HTTP/2 configuration for specific domains by checking the .htaccess file or any specific virtual host configurations.
Test HTTP/2 Performance
Once you’ve enabled HTTP/2 on your server, verify that it’s working correctly and see the performance benefits. The tool is WebPageTest.org, is excellent for this purpose. It allows you to run detailed performance tests from multiple locations around the world using real browsers.
Compare these new results with the old ones. Look for improvements in load times, reduced latency, and more efficient resource loading.
For additional reading and video tutorials, check out the following resources:
- Plesk Documentation on HTTP/2
- cPanel Documentation
- KeyCDN HTTP/2 Test Tool
- SSL Labs Test
- Main Resource of Article Sucuri Blog
By following these steps, you can enable HTTP/2 on your server, enhancing your website’s performance and providing a better experience for your users.