
nginx打上QUIC补丁,抢先体验http3
nginx据说早官方就表示会支持QUIC,但是迟迟没有发布相关的版本
主打安全和加速的CDN厂商cloudflare发布了基于nginx的QUIC补丁
安装环境依赖和编译工具
apt-get install build-essential automake autoconf make git cmake gcc
安装pcre,实现rewrite重写功能
1
2
3
4
5
wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
tar -zxvf pcre-8.44.tar.gz
cd pcre-8.44
./configure
make && make install
安装zlib, 实现gzip 压缩
1
2
3
4
5
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install
nginx安装
1
2
wget http://nginx.org/download/nginx-1.17.9.tar.gz
tar -zxvf nginx-1.17.9.tar.gz
1
git clone --recursive https://github.com/cloudflare/quiche
1
2
wget https://dl.google.com/go/go1.14.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.14.linux-amd64.tar.gz
添加环境变量
1
2
#/etc/profile
export PATH=$PATH:/usr/local/go/bin
cargo安装
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
可能需要使用source profile
命令使环境变量实时生效而无需重启
开始编译nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
cd nginx-1.17.9
patch -p01 < ../quiche/extras/nginx/nginx-1.16.patch
./configure --prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_v3_module \
--with-openssl=../quiche/deps/boringssl \
--with-quiche=../quiche \
--with-pcre=/opt/pcre-8.44 \
--with-zlib=/opt/zlib-1.2.11
make && make install
编译成功的nginx二进制文件在objs文件夹下
下面是nginx 开启QUIC的配置文件示例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
server {
# Enable QUIC and HTTP/3.
listen 443 quic reuseport;
# Enable HTTP/2 (optional).
listen 443 ssl http2;
listen 80;
server_name localhost;
ssl_certificate /var/www/example.com.cer;
ssl_certificate_key /var/www/example.com.key;
# Enable all TLS versions (TLSv1.3 is required for QUIC).
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
# Add Alt-Svc header to negotiate HTTP/3.
add_header alt-svc 'h3-24=":443"; ma=86400, h3-23=":443"; ma=86400';
...
}
/usr/local/nginx/sbin/nginx
查看nginx编译QUIC是否成功可以使用以下命令
/usr/local/nginx/sbin/nginx -V
查看ninx的端口监听
netstat -peanut | grep nginx
如果nginx监听了443 UDP端口,则表示成功。。。
或者使用lsof -i:443
,成功会显示如下图
1
2
3
nginx 10* root 6u IPv4 20320733 0t0 TCP *:https (LISTEN)
nginx 10* root 7u IPv4 20320734 0t0 UDP *:443
nginx 10* root 8u IPv6 20320735 0t0 TCP *:https (LISTEN)
https://pylist.com/t/1584076963
💘 相关文章
- nginx 开启http3 QUIC和配置Brotli压缩和反向代理的详细教程
- how to do config nginx allow's cloudflare ip's
- FreeBSD 安装PHP7.4 和 Nginx
- 解决nginx反向代理验证码不显示的方法
- Nginx – Unit nginx.service is masked的解决方法
- nginx 无缝停机添加模块
- nginx反向代理配置演示,包括静态资源处理,百分百成功
- nginx 使用gzip和Brotli压缩对比测试
- 怎样更新开源的http3服务器-openlitespeed
- digitalocean開源nginx可視化配置工具,非常適合新手小白,支持漢化