0%

Centos7/8超简单安装nginx-quic

nginx-quic是nginx正在开发中的支持http3的版本
目前网上大部分的文章都是基于源码编译安装的
但对于我这种只有一台垃圾服务器的玩家,源码编译不太现实
找了好久,终于找到一个可以直接yum安装的版本:
https://copr.fedorainfracloud.org/coprs/ryoh/nginx-quic/
其他发行版可能还是要源码编译。。。

安装后感觉是访问变快了,也可能是心理作用吧

安装

For CentOS 7

1
2
3
4
5
sudo yum install epel-release
sudo yum install centos-release-scl
sudo yum install yum-plugin-copr
sudo yum copr enable ryoh/nginx-quic
sudo yum install nginx-quic

For CentOS 8

1
2
3
sudo dnf install epel-release
sudo dnf copr enable ryoh/nginx-quic
sudo dnf install nginx-quic

备注:nginx 与 nginx-quic 不能共存,注意备份数据

配置:
server{}中添加

1
2
3
4
listen 443 http3 reuseport;  # UDP listener for QUIC+HTTP/3
ssl_protocols TLSv1.3; # QUIC requires TLS 1.3
add_header Alt-Svc '$http3=":443"; ma=86400'; # Advertise that QUIC is available
add_header QUIC-Status $quic;

检测是否成功

  1. https://http3check.net/

  2. Firefox启动
    about:config
    network.http.http3.enabled设置为true
    效果图如下

其他

1 首次启动失败

1
nginx: [emerg] cannot load certificate "/etc/pki/tls/certs/localhost.crt": BIO_new_file() ...

是因为在/etc/nginx/vhost.d/http/00-default.conf有配置本地签名
可以将其改名 00-default.conf_bak 或者在本地生成一个证书

1
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/pki/tls/private/localhost.key -out /etc/ssl/certs/localhost.crt

参考文档

  1. https://copr.fedorainfracloud.org/coprs/ryoh/nginx-quic/
  2. https://serverfault.com/questions/648534/accidently-removed-localhost-crt-ssl-in-centos-6-what-can-i-do
  3. https://zhuanlan.zhihu.com/p/159100819