All You Need to Know About HTTP2 (Nginx)

Posted by & filed under Web Servers.

nginx http/2

Launched in May 2015, this one is a relatively new protocol which was introduced after a long gap of 18 years. The earlier HTTP/1 was certified in the year 1997 and was in use since then. With a few changes and bringing more speed and advancement, the HTTP/2 is ready to tackle websites which have rich and complex content. Although the basics are the same but improvements have been made to enhance the user experience. The standardization efforts were supported by a number of browsers including Chrome, Internet Explorer 11, FireFox, Safari, and Edge. Following is a detailed account of HTTP/2:

What is HTTP/2?

Developed by the Hypertext Transfer Protocol working group, HTTP/2 is a major revision of the HTTP network protocol which has been consistently in use by the World Wide Web. The earlier experimental SPDY protocol which was originally developed by Google gave rise to this one. Also known as httpbis where bis stands for “second” as this is the only development which has occurred in the HTTP since HTTP/1.

It is actually not a re-write of the previous protocol, the status codes, and the semantics are the same though. It is possible to use the same APIs to represent the protocol with a few additions. The main focus of this protocol is the enhanced performance specifically the network and the server usage and improving end-user perceived latency.

Difference between HTTP/1 and HTTP/2

The changes which have been made to the first protocol do not require much of alterations in the way the applications work. Although, there is an advantage for new applications which will work on enhanced speed. The key differences between the two protocols have been listed below:

  1. The high-level syntax of both the protocols is the same. As already mentioned, the status codes, header fields, and URIs are the same. The modified element is the framing of the data and how it is transported between the server and the client.
  2. HTTP/2 allows responding to more queries which have been given by the client according to the data. This also enables the server to provide the data which is utilized by the browser to render a webpage. This is done without the requirement from the browser to examine the first response and without requesting for an additional overhead cycle.
  3. Efficient websites minimize the number of requests which are required to render a particular page. This means that the code is rendered into small packets carrying codes in them. This does not reduce the functionality but neither does it bring any convenience or efficiency for the browser.
  4. There was a head-of-line blocking problem in HTTP 1 which was overcome in the next protocol. This was done in HTTP/2 by multiplexing the responses and requests. Also, it helps in header compression and prioritization of requests.

Below is a good visual representation of the basic difference between HTTP/1 and HTTP/2 (courtesy : http://ruzhekov.com )

nginx http/2

Drawback for HTTP/2

This protocol has faced a lot of criticism because of its development process:

  1. The protocol is said to be inconsistent and carries with itself unnecessary and overwhelming complexities.
  2. It duplicates the flow control which violates the principle of protocol layering.
  3. There are HTTP applications which do not require any encryption but it comes with heavy encryption costs. People have no desire to spend additional resources but they are made to do so.
  4. It is stated that the present model certificate is not compatible with small devices like routers because annual enrollment and a non-trivial fee is involved in it.
  5. It has also been criticized for not supporting opportunistic encryption which is a strong measure against the passive monitoring. It is being considered mandatory that passive monitoring must be considered as an attack.

How to Install HTTP/2 with Nginx

Nginx is a dependable and fast web server which is open-source. The factors which made it so popular around the globe include ease of configuration, high scalability, memory footprint, and a support for a number of protocols. It has amazing compatibility with HTTP/2 which offers high-speed for websites which are rich in content.

Configuration

Nginx HTTP/2 is ideal for a number of reasons which include handling websites which have rich content. The first requirement is to update the list of packages which are available in the packaging system.

Afterward, check the version of Nginx. HTTP/2 is only compatible with Nginx version 1.9.5 onwards

Modify the site’s Nginx config file to listen to port 443

For more on how to install and configure SSL with Nginx, you can refer to this article : How to install LetsEncrypt Free SSL

Test the new nginx config

If the Nginx config test is successful, then restart nginx

After getting the output, you will be able to configure the Nginx HTTP/2 files and make a few changes which will optimize the performance. Also, check the syntax during the configuration process.

Although there are a number of drawbacks with this protocol but still it has proved to be a great discovery for handling more complex data. The criticisms are mostly related to encryption which can easily be overcome if a few things are worked upon and tweaked.

Leave a Reply