In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, the editor will show you how to enable Nginx's HTTP/2 protocol support on Linux. The knowledge points in this article are introduced in great detail. Friends who feel helpful can browse the content of the article with the editor, hoping to help more friends who want to solve this problem to find the answer to the problem. Let's follow the editor to learn more about "how to enable Nginx's HTTP/2 protocol support on Linux".
HTTP/2 is the main revised version of HTTP network protocol, which focuses on the performance improvement of HTTP protocol. The goal of the HTTP/2 protocol is to reduce latency and allow multiple requests to be initiated in parallel on a single connection between the Web browser and the server, so Web applications are faster.
We will show you how to use the Nginx-enabled HTTP/2 protocol on Linux VPS with Ubuntu or CentOS as the operating system.
Necessary conditions
In order to eventually enable the HTTP/2 protocol on the server according to this tutorial, you need to install Nginx first. And ensure that the function is normal and that there is no error in the configuration. You can check it out with the following command:
Sudo nginx-t
In addition, you need to have root access to the server, or at least one non-root system user with sudo access, so that you don't have permission problems when you modify the Nginx configuration file. Finally you need to have a domain name and a valid SSL certificate issued to the domain name.
Turn on Nginx's HTTP/2 protocol on Ubuntu
In order to open Nginx's HTTP/2 protocol on Ubuntu VPS, you need to edit the default Nginx server block, we use nano, you can use your own text editor.
Sudo nano / etc/nginx/sites-available/default
Add the following service blocks:
Server {server_name domain.com www.domain.com; listen 443 ssl http2 default_server; root / var/www/html; index index.html; location / {try_files $uri $uri/ = 404;} ssl_certificate / etc/nginx/ssl/domain.com.crt; ssl_certificate_key / etc/nginx/ssl/domain.com.key } server {listen 80; server_name domain.com www.domain.com; return 301 https://$server_name$request_uri;}
Make sure domain.com is replaced with your real domain name. In addition, the document root (root) directory should be set correctly, as well as the path to the SSL certificate and key.
When you have finished editing the service block, you need to save and close the file. Check the Nginx configuration for errors using the following command:
Sudo nginx-t
For the change to take effect, you need to restart Nginx:
Sudo systemctl restart nginx.service
If you want to open the HTTP/2 protocol for another domain name, you can see how our blog sets up Nginx service blocks on Ubuntu and CentOS.
Turn on Nginx's HTTP/2 protocol on CentOS
In order to turn on Nginx's HTTP/2 protocol in CentOS VPS, you need to follow exactly the same steps on Ubuntu. The only difference is the location of the Nginx block file. In order to edit the default Nginx service block on CentOS, you need to enter the / etc/nginx/conf.d folder.
# nano / etc/nginx/conf.d/default.conf
Check the configuration again for errors, save and close the file, and then restart the Nginx service using the following command:
# systemctl restart nginx.service
To check whether Nginx's HTTP/2 protocol is turned on successfully, you can use some online HTTP/2 detection tools.
Thank you for reading, the above is the whole content of "how to enable Nginx HTTP/2 protocol support on Linux", learn friends to hurry up to do it. I believe that the editor will certainly bring you better quality articles. Thank you for your support to the website!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.