JIYIK CN >

Current Location:Home > Learning > NETWORK >

HTTP2 Tutorial - How to Configure HTTP2 with Nginx

Author:JIYIK Last Updated:2025/03/17 Views:

HTTP2 was officially released in 2015. If your website is still using HTTP/1.1, you may be out of date. Don't worry, here we will see how to use Nginx to upgrade your website to HTTP2.

Install Nginx

I feel that this column is redundant. Since we are talking about using Nginx to configure HTTP2, of course we must install Nginx. And Nginx installation is everywhere. So here we will not talk about how to install Nginx in detail. We will only talk about two specific points.

First of all, the version of Nginx cannot be lower than Nginx 1.10. Then, the default compiled Nginx does not include the h2 module, so we need to add parameters to compile it.

$ ./configure --with-http_v2_module
# 然后就是编译安装了
$ make && make install

HTTP2 needs to be used together with HTTPS . Therefore, openssl support is required. The openssl version here also has requirements. The minimum requirement is 1.0.2. If it is not met, you have to manually download openssl and then use –with-openssl to specify the openssl directory when compiling.

Configure Nginx

Here, without further ado, let's go straight to the configuration

server {
        listen          443 ssl http2;
        listen          [::]:443 ssl http2;
        server_name     www.jiyik.com jiyik.com;

        ssl_certificate /certificates/www.jiyik.com/fullchain.pem;
        ssl_certificate_key /certificates/www.jiyik.com/privkey.pem;
        ssl_trusted_certificate /certificates/www.jiyik.com/fullchain.pem;

        ssl_session_timeout 1d;
        ssl_session_cache shared:SSL:50m;
        ssl_session_tickets off;

Some of the configuration items are shown here, and the rest can be supplemented online.

Check if HTTP2 is supported

After completing the above configuration, restart Nginx. Then visit our website and check whether HTTP2 is supported through the developer tools of the Chrome browser.

Chrom checks whether it supports http2

Here is a Chrome extension HTTP/2 and SPDY indicator that can be used to check whether HTTP2 is supported.

The results are as follows

Jiyike supports HTTP2 example

Recommended reading: HTTP2 Tutorial - The Past and Present of HTTP2   and HTTP2 Tutorial - Functional Upgrade of HTTP2

For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.

Article URL:

Related Articles

Nginx load balancing settings

Publish Date:2025/03/18 Views:198 Category:NETWORK

At this stage, load balancing is a widely used technology. Nginx, as a load balancing server for http, is being used more and more widely. There are three ways to set up Nginx load balancing: Round-robin - This method distributes access req

Nginx load balancing health_check analysis

Publish Date:2025/03/18 Views:54 Category:NETWORK

In Nginx load balancing, it is difficult to guarantee that every application server can run normally all the time. However, we can set Nginx to detect these application servers and detect which of them are inaccessible. There are two ways t

HTTP2 Tutorial - The Past and Present of HTTP2

Publish Date:2025/03/16 Views:73 Category:NETWORK

HTTP was originally proposed by Timberners-Lee, a pioneer of the World Wide Web, who designed the application protocol with simplicity in mind to perform advanced data communication functions between web servers and clients. The first docum

HTTP2 Tutorial - The shortcomings of HTTP1.1

Publish Date:2025/03/16 Views:145 Category:NETWORK

HTTP 1.1 is limited to handling only one outstanding request per TCP connection, forcing browsers to use multiple TCP connections to handle multiple requests simultaneously. However, using too many TCP connections in parallel can cause TCP

HTTP2 Tutorial - HTTP2 Functional Upgrade

Publish Date:2025/03/16 Views:87 Category:NETWORK

Before we officially introduce the functions of HTTP/2, let's take a detour to understand the past and present of HTTP/2 . Multiplexing Streams The bidirectional sequence of text-formatted frames sent via the HTTP/2 protocol exchanged betwe

HTTP2 Tutorial - How to use HTTP/2 with HTTPS

Publish Date:2025/03/16 Views:84 Category:NETWORK

HTTPS is used to build ultra-secure networks connecting computers, machines, and servers to handle sensitive business and consumer information. HTTP/2 browser support includes HTTPS encryption, which actually complements the overall securit

Deep understanding of Nginx's server block selection algorithm

Publish Date:2025/03/17 Views:95 Category:NETWORK

Nginx is one of the most popular web servers in the world. It can successfully handle high loads with many concurrent client connections and can be used as a web server, mail server, or reverse proxy server. In this article, we will discuss

In-depth understanding of Nginx Location block matching algorithm

Publish Date:2025/03/17 Views:61 Category:NETWORK

Similar to the process that Nginx uses to select the Server block that will handle a request  , Nginx also has an established algorithm to decide which Location block within a Server block to use to handle a request. location block syntax

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial