配置br
需要安装
【方法1】通过编译nginx时注入安装,以docker为例
FROM ubuntu:22.04
ARG NGINX_VERSION="1.23.4"
RUN set -x
RUN apt-get update
RUN apt-get install curl build-essential libtool libpcre3 libpcre3-dev zlib1g-dev libssl-dev openssl git -y
WORKDIR /home/nginx
RUN git clone --recurse-submodules https://github.com/google/ngx_brotli.git
RUN curl -O http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
RUN tar -xvf nginx-${NGINX_VERSION}.tar.gz
WORKDIR /home/nginx/nginx-${NGINX_VERSION}
RUN ./configure --prefix=/opt/nginx --add-module=/home/nginx/ngx_brotli --with-http_ssl_module
RUN make
RUN make install
【方法2】对现有nginx二进制进行动态注入(略)
填写
在nginx根目录下的nginx.conf文件中,找到http项目,里面填写
brotli on;
brotli_comp_level 6;
brotli_buffers 16 8k;
brotli_min_length 20;
brotli_types
text/plain
text/css
application/json
application/x-javascript
text/xml
application/xml
application/xml+rss
text/javascript
application/javascript
image/svg+xml;
brotli_static on;