Oracle Linux 8.3 template is now available

How to Configure HTTP/2 in Nginx on Ubuntu 20.04

Joe Harris
December 17, 2020

HTTP/2 is an improved version of the HTTP protocol that allows you to increase the speed of the site and reduce the load on the web server. All this is possible by making multiple simultaneous requests in a single TCP connection. Increasing the speed not only improves the user experience with the site, but potentially even elevates its position in the search engine results. In this tutorial we will look at how to configure HTTP/2 in the Nginx web server on the Ubuntu 20.04 system.

Necessary conditions:

Preparing the system for HTTP/2

First, you need a fresh version of the Nginx web server to be able to enable HTTP/2. Update the packages in the system.

apt update && apt upgrade

Configuring the HTTP/2 in Nginx

Open the configuration file of your virtual host.

nano /etc/nginx/sites-available/

Find this line in it:

listen 443 ssl;

Add http2 here:

listen 443 ssl http2;

If you see the line, starting with:

listen [::]:443 ssl ...

Then add http2 in it too.

listen [::]:443 ssl http2 ...

Save and close the file, and check the configuration for errors.

nginx -t

Restart Nginx.

systemctl restart nginx

That's it, the HTTP/2 protocol is enabled on your website.

Check if the HTTP/2 is enabled

You can check whether HTTP / 2 is enabled directly in the command line of any Linux machine. To do this, you need to install curl. For example, for Ubuntu:

apt install curl

Now enter this command with your FQDN in it:

curl -I


HTTP/2 200

This means that your site is currently using HTTP/2.

Another way to check it is to use this service:

Start your cloud journey. Take the first step right now.
We use cookies to provide our services and for analytics and marketing. To find out more about our use of cookies, please see our Privacy Policy. By continuing to browse our website, you agree to our use of cookies.