Nginx开启HTTP/3.0

2024-08-07 13:36:37 浏览数 (2)

Nginx开启HTTP/3.0

官方文档

HTTP/3.0 是 HTTP/2.0 的下一代版本,由谷歌开发; Nginx 从 1.25.0 版本开始支持 HTTP/3.0

编译安装 Nginx

代码语言:javascript复制
# 默认不编译 HTTP/3 模块
./configure --prefix=/usr/local/nginx --with-http_v3_module

配置 Nginx

代码语言:javascript复制
vim /usr/local/nginx/conf/nginx.conf

http {
    log_format quic '$remote_addr - $remote_user [$time_local] '
                    '"$request" $status $body_bytes_sent '
                    '"$http_referer" "$http_user_agent" "$http3"';
   ...
   
   server {
       listen 80;
       listen [::]:80;
       listen 443 ssl;
       listen [::]:443 ssl;
       listen 443 quic reuseport;	# 配置 H3 协议守护,注意reuseport放在默认虚机
       listen [::]:443 quic reuseport;
       server_name xx.xxx.com;
       
       ssl_certificate
       ssl_certificate_key 
       
       location / {
           root html/;
           index index.html;
           add_header Alt-Svc 'h3=":443"; ma=86400';	# 这个是告知客户端支持H3,需要这个才会访问到H3
       }
   }
}

0 人点赞