nginx-quic

安装并使用nginx-quic

① 安装boringssl

https://github.com/google/boringssl
在这里插入图片描述
通过xftp上传到nginx所在主机的/usr/local/目录下。

unzip boringssl-master.zip -d /usr/local/

mv boringssl-master boringssl

mkdir build

cd build

apt install gcc

apt install g++

cmake …

make


② 安装nginx-quic

https://hg.nginx.org/nginx-quic
在这里插入图片描述
在这里插入图片描述
通过xftp上传到nginx所在主机的/usr/local/目录下。

unzip nginx-quic.zip -d /usr/local/

mv nginx-quic-9ea62b6250f2 nginx

cd nginx

sudo apt-get install libpcre3 libpcre3-dev

sudo apt-get install zlib1g-dev

./auto/configure --with-debug --with-http_v3_module \
–with-stream_quic_module \
–with-cc-opt=“-I…/boringssl/include” \
–with-ld-opt=“-L…/boringssl/build/ssl \
-L…/boringssl/build/crypto”

make && make install

cd /usr/local/nginx

mkdir logs

cd logs

touch access.log error.log

为了更方便的使用nginx,将可执行文件加入环境变量:
vim /etc/profile

export NGINX_HOME=/usr/local/nginx
export PATH=$PATH:$NGINX_HOME/sbin

source /etc/profile


③ 申请域名并下载SSL证书

3.1 在腾讯云申请域名,并解析到nginx所在主机的IP。
3.2 为域名签发证书。
3.3 签发成功后,下载证书

在这里插入图片描述
需要key和pem这两个文件。
在这里插入图片描述
将.key文件和.pem文件放在/usr/local/nginx/conf/certs目录下。


④ 修改nginx.conf配置文件

events {
    worker_connections  1024;
}

http {
    log_format quic '$remote_addr - $remote_user [$time_local] '
                        '"$request" $status $body_bytes_sent '
                        '"$http_referer" "$http_user_agent" ';

    access_log logs/access.log quic;

    server {
        # for better compatibility it's recommended
        # to use the same port for quic and https
        listen 8443 quic reuseport;
        listen 8443 ssl;

        ssl_certificate     certs/www.cantina.top_bundle.pem;
        ssl_certificate_key certs/www.cantina.top.key;
            
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
           
        location / {
            # required for browsers to direct them into quic port
            add_header Alt-Svc 'h3=":8443"; ma=86400';
        }
    }
}

⑤ 测试nginx.conf,启动nginx

nginx -t
nginx
ps -ef | grep nginx
在这里插入图片描述

浏览器默认不支持http3,需要修改配置后重启。

Google Chrome

在浏览器地址栏输入并回车:chrome://flags/#enable-quic
将 Experimental QUIC protocol 设置为 Enabled
在这里插入图片描述

Mozilla Firefox

在浏览器地址栏输入并回车:about:config

将 network.http.http3.enabled 设置为 true
在这里插入图片描述

Microsoft Edge

在浏览器地址栏输入并回车:edge://flags/#enable-quic

将 Experimental QUIC protocol 设置为 Enabled
在这里插入图片描述


在这里插入图片描述

通过浏览器访问https://www.cantina.top:8443进行测试。
查看access.log:

Chrome:

在这里插入图片描述

Edge:

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值