作者 | 阿文
责编 | 郭芮
出品 | CSDN(ID:CSDNnews)
HTTP over QUIC
,QUIC 是快速UDP网络连接的简称,由Google公司研发,该协议旨在取代TCP协议,使网页传输更快、更稳定、更安全。
为什么使用UDP+QUIC?
如何使用 HTTP/3?
curl -O https://nginx.org/download/nginx-1.16.1.tar.gz
tar xzvf nginx-1.16.1.tar.gz
git clone --recursive https://github.com/cloudflare/quiche
3.使用patch将补丁引入:
cd nginx-1.16.1
patch -p01 < ../quiche/extras/nginx/nginx-1.16.patch
./configure \
--prefix=$PWD \
--build="quiche-$(git --git-dir=../quiche/.git rev-parse --short HEAD)" \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_v3_module \
--with-openssl=../quiche/deps/boringssl \
--with-quiche=../quiche
make
server {
listen 80;
# Enable HTTP/2 (optional).
listen 443 ssl http2;
# Enable QUIC and HTTP/3.
listen 443 quic reuseport;
server_name www.awen.me;
root /vdata/www/default;
index index.html;
ssl_certificate /usr/local/nginx/ssl/awen.me.crt;
ssl_certificate_key /usr/local/nginx/ssl/awen.me.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ……
# Add Alt-Svc header to negotiate HTTP/3.
add_header alt-svc 'h3-23=":443"; ma=86400';
……
}
add_header alt-svc 'h3-23=":443"; ma=86400';
,客户端请求类似如下:
Alt-Svc
全称为“Alternative-Service”,直译为“备选服务”。该头部列举了当前站点备选的访问方式列表。一般用于在提供 “QUIC” 等新兴协议支持的同时,实现向下兼容。