brotli with openresty or nginx

  • Category: 電腦相關
  • Last Updated: Tuesday, 11 April 2023 14:59
  • Published: Tuesday, 11 April 2023 11:43
  • Written by sam

Install "brotli" and got many errors.......

Check nginx version.

[root@cms brotli]$>nginx -V
nginx version: openresty/1.21.4.1
built with OpenSSL 1.1.1n  15 Mar 2022 (running with OpenSSL 1.1.1s  1 Nov 2022)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl111/include' --add-module=../n/echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.33 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.09ule-0.32 --add-module=../ngx_lua-0.10.21 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nedis-nginx-module-0.3.9 --add-module=../ngx_stream_lua-0.0.11 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl111/lib -Wl,-rpath,/local/openresty/pcre/lib:/usr/local/openresty/openssl111/lib' --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --withtub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_--with-http_mp4_module --with-http_gunzip_module --with-threads --with-stream --with-http_ssl_module

Get it.

[root@cms tmp]$>wget https://openresty.org/download/openresty-1.21.4.1.tar.gz

Unzip

[root@cms tmp]$>tar -zxvf openresty-1.21.4.1.tar.gz
[root@cms tmp]$>cd openresty-1.21.4.1/

Download brotli, don't forget add --recursive

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

Config

[root@cms openresty-1.21.4.1]$>./configure --add-dynamic-module=/usr/local/openresty/ngx_brotli

An Error.

platform: linux (linux)
cp -rp bundle/ build
cd build
cd LuaJIT-2.1-20220411
Can't exec "cc": No such file or directory at ./configure line 719.

Resolve.

[root@cms openresty-1.21.4.1]$>apt install gcc

If you got an error missing...

./configure: error: Brotli library is missing from the /usr directory.

Resolve.

must add --recursive when you git clone.

An error.

./configure: error: the HTTP rewrite module requires the PCRE library.

Resolve.

[root@cms openresty-1.21.4.1]$>apt-get install libpcre3 libpcre3-dev

An error.

./configure: error: SSL modules require the OpenSSL library.

Resolve.

[root@cms openresty-1.21.4.1]$>apt-get install libssl-dev

An error.

./configure: error: the HTTP gzip module requires the zlib library.

Resolve.

[root@cms openresty-1.21.4.1]$>apt install zlib1g zlib1g-dev

Make. and make install, or only make and copy to your path.

[root@cms openresty-1.21.4.1]$>make
/tmp/openresty-1.21.4.1/build/nginx-1.21.4/objs

Add to nginx.conf

user  www-data;
worker_processes  auto;
worker_rlimit_nofile 65535;
load_module "ngx_http_brotli_static_module.so";
load_module "ngx_http_brotli_filter_module.so";

Finish.

[root@cms conf]$>nginx -V
nginx version: openresty/1.21.4.1
built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
built with OpenSSL 1.1.1n  15 Mar 2022
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=d-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.09 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.21 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more/array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.9 --add-module=../rds-json-nginx-module-0.15 --add-module=../rds-csv-nginx-module-0.0.0.11 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib --add-module=/tmp/openresty-1.21.4.1/ngx_brotli --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_ssl_module