nginx 开启http3 QUIC和配置Brotli压缩和反向代理的详细教程
nginx 开启http3 QUIC和配置Brotli压缩和反向代理的详细教程
nginx 配置http3 QUIC参阅这篇文章
在上面的配置中编译Nginx时添加以下代码
1
2
git clone https://github.com/google/ngx_brotli
cd ngx_brotli && git submodule update --init
下面时演示代码,具体路径自行修改
1
2
3
4
5
6
7
8
9
10
11
12
./configure --prefix=/usr/local/nginx --user=www-data --group=www-data --pid-path=/var/run/ginx.pid \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_v3_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-http_realip_module \
--add-module=/opt/ngx_brotli \
--with-openssl=../quiche/deps/boringssl \
--with-quiche=../quiche \
--with-pcre=/opt/pcre-8.44 \
--with-zlib=/opt/zlib-1.2.11
nginx.conf
的server
段
1
2
3
4
# brotli
brotli on;
brotli_comp_level 5;
brotli_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml
如果安装遇到问题,请自行参考以下文章
下面时配置nginx反向代理
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
location / {
proxy_pass http://127.0.0.1:9090;
proxy_set_header Host $host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 300;
proxy_read_timeout 300;
proxy_send_timeout 300;
}
location ^~ /avatar/ {
root /home/wwwroot/demo/static;
}
//请求头像地址直接在网站根目录static目录下查找
location ~* \.(js|css)$ {
root /home/wwwroot/demo/static/;
}
//同上
location ~* \.(gif|ico|bmp|png|jpg|jpeg)$ {
root /home/wwwroot/demo/upload;
}
//图片的存放目录
💘 相关文章
- 重新编译nginx,以便支持最新的quic(http3)以及 brotli 压缩
- nginx打上QUIC补丁,抢先体验http3
- 在ARM服务器中基于ubuntu系统一键架设nginx quic http3环境
- nginx 使用gzip和Brotli压缩对比测试
- openLitespeed的教程
- 快速简单一键搭建nginx quic的环境
- openwrt使用Nginx 替代uhttpd
- nginx: [warn] "ssl_stapling" ignored, not supported告警
- 注册nginx的systemctl服务
- nginx配置时HTTPS出现"nginx: [warn] "ssl_stapling" ignored"的解决方法