nginx启用HTTP2特性,开启brotli压缩

本站编译环境如下

nginx version: nginx/*****
built by gcc ***** GCC)
built with OpenSSL 1.*****
TLS SNI support enabled
configure arguments: –prefix=/work/apps/nginx –with-http_stub_status_module –without-select_module –without-poll_module –with-debug –with-http_ssl_module –with-http_realip_module –with-http_v2_module –http-log-path=/data/log/nginx/access.log –error-log-path=/data/log/nginx/nginx_error.log –pid-path=/var/run/nginx.pid –with-openssl=/work/apps/openssl –add-module=/work/soft/gitsoft/ngx_brotli

修改编译选项
configure的选项中加入--with-http_v2_module,由于HTTP2需要SSL的支持,因此如缺少--with-http_ssl_module选项,还需要加入--with-http_ssl_module

使用git下载brotli

git clone https://github.com/google/ngx_brotli.git

要使用git submodule update 更新brotli的子模块,否则编译不完整

brotli 配置如下

brotli on;
brotli_comp_level 6;
brotli_buffers 16 8k;
brotli_min_length 20;
brotli_types *;

brotli可以和gzip共存,brotli 需要https才可使用

 

 

发表评论