JIYIK CN >

Current Location:Home > Learning > NETWORK >

HTTP2 Tutorial - How to Configure HTTP2 with Nginx

Author:JIYIK Last Updated:2025/04/14 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

How to Install Nginx on Ubuntu 20.04?

Publish Date:2025/04/07 Views:157 Category:OPERATING SYSTEM

Nginx is one of the most popular web servers in the world, responsible for hosting some of the largest and most trafficked sites on the Internet. It is a lightweight application software that can be used as a web server or a reverse proxy.

Install WordPress with Nginx on Ubuntu 18.04

Publish Date:2025/04/07 Views:86 Category:OPERATING SYSTEM

WordPress is one of the most popular open source content management systems (CMS) with a market share of up to 60% compared to other CMS like Drupal or Joomla. WordPress can be used to develop any type of website, be it a blog, a small busi

Docker deploys nginx php application

Publish Date:2025/03/26 Views:131 Category:Docker

I'm learning docker recently. I'm learning by building an nginx+php development environment example. Here I record the build process. First, give a docker-compose.yml deployment configuration file version: '3' services: nginx: container_nam

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:56 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

Scan to Read All Tech Tutorials

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

Recommended

Tags

Scan the Code
Easier Access Tutorial