0°

nginx开启brotli

1159 个字符,0 张图片,大约需要 2 分钟阅读

下载brotli

cd /tmp
git clone https://github.com/google/ngx_brotli.git
cd ngx_brotli/deps/brotli
git clone git@github.com:google/brotli.git (git clone https://github.com/google/brotli.git)

下载nginx

cd /usr/local/src
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar xzvf nginx-1.12.2.tar.gz
cd nginx-1.12.2

编译nginx

/usr/local/nginx/sbin/nginx -V
./configure --add-module=/tmp/ngx_brotli + 上面看到的
make

移动备份覆盖

mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
cp objs/nginx /usr/local/nginx/sbin/

测试nginx

/usr/local/nginx/sbin/nginx -t

nginx.conf添加

gzip on;
gzip_min_length  1k;
gzip_buffers     4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied   expired no-cache no-store private auth;
gzip_disable   "MSIE [1-6]\.";
brotli on;
brotli_types text/plain text/css text/xml application/xml application/json text/javascript application/javascript application/x-javascript
brotli_static off;
brotli_comp_level 11;
brotli_buffers 16 8k;
brotli_window 512k;
brotli_min_length 20;

除非注明,否则均为喵喵喵博客原创文章,转载请以链接形式标明本文地址

本文链接:https://www.miaomiaomiao.org/7.html

0 条回复 A 作者 M 管理员
    当上帝赐给你荒野时,就意味着,他要你成为高飞的鹰
欢迎您,新朋友,感谢参与互动!欢迎您 {{author}},您在本站有{{commentsCount}}条评论