HTTP3初体验 | 青训营笔记

291 阅读1分钟

这是我参与「第五届青训营」伴学笔记创作活动的第 5 天

重点内容

HTTP/3试水

详细知识点介绍

小看一眼,发现全是编译啥的。应该会踩很多坑的,这次用国外没东西的小1h512M服务器试水一下。 目前cloudflare给出了一键开启http3。很好用,我在netlify托管的网页一键开开了。 1 2

实践练习例子

现在要编译安装一个nginx,用的是github.com/cloudflare/…方案。 github.com/cloudflare/…处理nginx的教程在这里,一步步跟上

  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
  cd nginx-1.16.1
  patch -p01 < ../quiche/nginx/nginx-1.16.patch

在之前要apt upgrade一下避免有装不上的东西 3 外网服务器下的就是快😎 要编译了发现cmake没有 装个cmake先 apt install cmake

gcc g++也没有 装个

接下来

  ./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/quiche/deps/boringssl \
       --with-quiche=../quiche
  make

nginx configure 时候报错, the HTTP rewrite module requires the PCRE library. 搜了 装这个 apt install libpcre3 libpcre3-dev

the HTTP gzip module requires the zlib library 搜了 装这个 apt install zlib1g-dev

又error 没有cargo 装个 apt install cargo

make好了

nginx -V

装是装好了 好像要一个https证书啊 acme签一个 https://github.com/acmesh-official/acme.sh/wiki/%E8%AF%B4%E6%98%8E

events {
    worker_connections  1024;
}
​
http {
    server {
        # Enable QUIC and HTTP/3.
        listen 443 quic reuseport;
​
        # Enable HTTP/2 (optional).
        listen 443 ssl http2;
​
        ssl_certificate      cert.crt;
        ssl_certificate_key  cert.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=":443"; ma=86400';
    }
}

签证书签了半天 签好了 放在

        ssl_certificate      cert.crt;
        ssl_certificate_key  cert.key;

里面 配置好nginx 注意网站不要在root下 在root下nginx访问不到直接403了 建一个/www/wwwroot/domin文件夹放东西

最后配置结果是这样滴

第一个

geekflare.com/tools/test/… 6 这个网站会检测什么h3-xxx的版本协议 (看不懂,看懂了在写一篇 你没有这个版本号的协议这个网站就检测不出来好像 在这里改就行 add_header alt-svc 'h3=":443"; ma=86400'; 我加了版本号114514🤓 add_header alt-svc h3=":443"; ma=86400; h3-114514=":443"; ma=86400 上面这个好像就检测这个alt-svc这个头

第二个

http3check.net/?host=http3… 7 这个就很正常了 不加版本直接检测h3的

第三个

然后是wappalyzer插件 8

第四个

然后是浏览器devtools的协议检查 9

课后个人总结

🤥感觉没啥可总结的

国外服务器也测不了http3优势啥的

下载速度到国内就慢的一了

下班!睡觉!😝

引用参考

zhuanlan.zhihu.com/p/405387352

github.com/cloudflare/…

http3check.net/about