HTTP/2 is the latest version of the Hypertext Transfer Protocol (HTTP), which allows web browsers and servers to communicate more efficiently and securely. In this post, we’ll discuss how to configure HTTP/2 with WHM/cPanel and NGINX on CentOS 7 using WHM’s NGINX Manager to install NGINX and WHM’s terminal to access SSH instead of SSH through Putty or something else. We’ll assume that the user has AutoSSL configured for the SSL certificate.
Step 1: Install NGINX using WHM’s NGINX Manager
WHM’s NGINX Manager is a plugin that allows you to install and manage NGINX on your server directly from WHM. To install NGINX using NGINX Manager, follow these steps:
- Log in to WHM as the root user.
- Click on “Plugins” in the left-hand menu.
- Click on “NGINX Manager.”
- Click on “Install” to install NGINX.
- Wait for the installation process to complete.
Step 2: Ensure all sites on the Server use SSL w/AutoSSL
HTTP/2 requires SSL encryption, so you’ll need to make sure your sites have an SSL certificate. If you already have an SSL certificate installed on all of your sites and server hostname, you can skip this step.
To Double Check AutoSSL Is Configured Correctly For All Domains:
- Log in to WHM as the root user.
- Click on “SSL/TLS” in the left-hand menu.
- Click on “Manage AutoSSL Hosts.”
- Click on “Allow AutoSSL to replace invalid or expiring non-AutoSSL certificates.”
- Click on “Save”
- Click on “Run AutoSSL For All Users”
- Click on “Logs”
- Click on “Refresh”
- Look for the Log with the + next to it or just the top most recent timed one and click it
- Click “View” (You may need to click this a few time until it it done and possibly steps 8 thru 10)
- If the Log file has this line “The “Sectigo” provider cannot currently accept incoming requests. The system will try again later.” near the bottom you may want to go back to the “Providers” tab and switch to “Let’s Encrypt™” instead of “Sectigo”.
Step 3: Configure NGINX for HTTP/2
Next, you’ll need to configure NGINX to support HTTP/2. To do this, follow these steps:
- Log in to WHM as the root user.
- Click on “Server Configuration” in the left-hand menu.
- Click on “Terminal”
- “nano /etc/nginx/conf.d/http2.conf”
- Add the following lines:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
}
6. Press “Control/Ctrl”+”X”, then “Y”, and “Enter/Return”. This will save the file and bring you back to the terminal prompt
7. Type “nginx -t” which should say that a ton of duplicates are in the configuration files but it should say overall the configuration is good.
Step 4: Restart NGINX and test HTTP/2
Finally, restart NGINX by running the following command in WHM’s terminal:
systemctl restart nginx
To test if HTTP/2 is working, visit your website using a web browser and open the developer tools. Look for the protocol version being used, which should be HTTP/2. If it’s not working, check your NGINX configuration and SSL certificate.