Dbian10编译nginx实验部署HTTP3(Quiche)

前面我们写过centos7编译nginx支持http的实验部署,这次我们使用新版的Debian10实现编译,主要是看有哪些小的注意点。使用nginx-1.19.0版本和0.4.0版本的Cloudflare开发的quiche

1.安装依赖软件及更新

sudo apt update &&  apt upgrade && dist-upgrade && apt autoremove
apt install make build-essential clang golang cmake -y

2.安装构建quiched的Rust cargo

 curl https://sh.rustup.rs -sSf | sh

选择1按照默认设置安装,然后执行临时系统环境设置,并测试cargo是否输出

 source $HOME/.cargo/env
cargo -v

由于cargo的Rust Crates 源在国外,国内在编译调用在线的依赖的时候很慢很慢,我们更新使用国内中科大的源.新增cargo的配置文件$HOME/.cargo/config

vim $HOME/.cargo/config

[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

这里对debian有一个问题,编译的时候bash命令好像不会寻找系统环境中我们刚才安装的cargo命令,会出现/bin/sh: cargo: 未找到命令,因此我们专门做一条软链便于系统寻找cargo命令。

 ln -s $HOME/.cargo/bin/cargo /usr/local/bin/cargo

3.nginx编译参数,nginx configure参数需要包含以下内容

--build="quiche-$(git --git-dir=../quiche/.git rev-parse --short HEAD)" --with-http_v3_module  --with-openssl=../quiche/deps/boringssl --with-quiche=../quiche
4.具体编译nginx和正常一样即可

5.nginx网站配制参数

# Enable QUIC and HTTP/3.
listen 443 quic reuseport;
 
# Enable HTTP/2 (optional).
listen 443 ssl http2;

# Add Alt-Svc header to negotiate HTTP/3.
add_header alt-svc 'quic=":443"; ma=2592000; v="46,43",h3-27=":443"; ma=2592000,h3-25=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000';

6.测试,可以使用https://http3check.net进行测试.

至此,我们完成了http3在debian10上的部署,主要核心还是要搞定cargo组件,有点麻烦!See U!

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注