HTTP2 Tutorial - How to Configure HTTP2 with Nginx
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.
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
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.
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.
How to use Let's Encrypt with Nginx to configure https in Ubuntu 20.04
Publish Date:2025/04/07 Views:123 Category:OPERATING SYSTEM
-
Let's Encrypt is a Certificate Authority (CA) that provides an easy way to obtain and install free TLS/SSL certificates, enabling encrypted HTTPS on your web server. It simplifies the process by providing a software client, Certbot, which a
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
Solution to incorrect access log time when deploying Nginx in Docker
Publish Date:2025/03/26 Views:165 Category:Docker
-
In the process of operating the website, I never took the logs too seriously. Although logging was turned on, I never analyzed the logs carefully. Today, when I looked at the logs on a whim, I found that the recorded time was 8 hours less t
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