简体   繁体   中英

ngx_http_brotli_filter_module.so" is not binary compatible in /etc/nginx/nginx.conf:1

Using Nginx 1.17.3 and Nginx 1.14.0 on Ubuntu 18.* on two separate servers. Both show same error ngx_http_brotli_filter_module.so" is not binary compatible .

Nginx was installed using sudo apt install nginx , so --with-compat flag is applied automatically don't know about it.

Using below script to make modules

# For predefined NGINX version, use:
 ngver=1.14.0

# Get configure parameters of installed NGINX. Not needed if NGINX was configured '--with-compat'.
# Uncomment one of the lines below if the script sucessfully builds modules but NGINX throws a "not binary compatible" error.
 confparams=$(nginx -V 2>&1 | grep -o -- '--prefix='.*)
# confparams=$(nginx -V 2>&1 | grep -o -- '--[^with]'.*)
# confparams=$(nginx -V 2>&1 | grep -- '--' | sed "s/.*' //")
# confparams=$(nginx -V 2>&1 | grep -o -- "--prefix='.*'$")

# To automatically select NGINX modules directory:
[ -d /usr/share/nginx/modules ] && moddir=/usr/share/nginx/modules
[ -d $(nginx -V 2>&1 | grep -o 'prefix=[^ ]*' | sed 's/prefix=//')/modules ] && moddir="$(nginx -V 2>&1 | grep -o 'prefix=[^ ]*' | sed 's/prefix=//')/modules"
[ -d $(nginx -V 2>&1 | grep -o 'modules-path=[^ ]*' | sed 's/modules-path=//') ] && moddir="$(nginx -V 2>&1 | grep -o 'modules-path=[^ ]*' | sed 's/modules-path=//')"
[ "${moddir}" ] || { echo '!! missing modules directory, exiting...'; exit 1; }

# Set temporary directory and build on it
builddir="$(mktemp -d)"
cd "${builddir}"

echo
echo '################################################################################'
echo
echo "Building Brotli for NGINX ${ngver}"
echo "Temporary build directory: ${builddir}"
echo "Modules directory: ${moddir}"
echo

# Download and unpack NGINX
wget https://nginx.org/download/nginx-${ngver}.tar.gz && { tar zxf nginx-${ngver}.tar.gz && rm nginx-${ngver}.tar.gz; } || { echo '!! download failed, exiting...'; exit 2; }

# Download, initialize, and make Brotli dynamic modules
git clone https://github.com/google/ngx_brotli.git
cd ngx_brotli && git submodule update --init && cd ../nginx-${ngver}
[ "${confparams}" ] && nice -n 19 ionice -c 3 "./configure --add-dynamic-module=../ngx_brotli ${confparams}" || nice -n 19 ionice -c 3 ./configure --with-compat --add-dynamic-module=../ngx_brotli
nice -n 19 ionice -c 3 make modules || { echo '!! configure or make failed, exiting...'; exit 4; }

# Replace Brotli in modules directory
[ -f "${moddir}/ngx_http_brotli_filter_module.so" ] && sudo mv "${moddir}/ngx_http_brotli_filter_module.so" "${moddir}/ngx_http_brotli_filter_module.so.old"
[ -f "${moddir}/ngx_http_brotli_static_module.so" ] && sudo mv "${moddir}/ngx_http_brotli_static_module.so" "${moddir}/ngx_http_brotli_static_module.so.old"
sudo cp objs/*.so "${moddir}/"
sudo chmod 644 "${moddir}/ngx_http_brotli_filter_module.so" || { echo '!! module permissions failed, exiting...'; exit 5; }
sudo chmod 644 "${moddir}/ngx_http_brotli_static_module.so" || { echo '!! module permissions failed, exiting...'; exit 6; }

Tried building modules using --with-compat with and without, both are showing same error ngx_http_brotli_filter_module.so" is not binary compatible in /etc/nginx/nginx.conf:1

Below is output from above script, tried it on another server with Nginx 1.17.3 version installed.

Temporary build directory: /tmp/tmp.fR4QK184b3
Modules directory: /usr/lib/nginx/modules

--2020-08-10 07:13:12--  https://nginx.org/download/nginx-1.14.0.tar.gz
Resolving nginx.org (nginx.org)... 52.58.199.22, 3.125.197.172, 2a05:d014:edb:5702::6, ...
Connecting to nginx.org (nginx.org)|52.58.199.22|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1016272 (992K) [application/octet-stream]
Saving to: ‘nginx-1.14.0.tar.gz’

nginx-1.14.0.tar.gz                  100%[=====================================================================>] 992.45K   524KB/s    in 1.9s

2020-08-10 07:13:15 (524 KB/s) - ‘nginx-1.14.0.tar.gz’ saved [1016272/1016272]

Cloning into 'ngx_brotli'...
remote: Enumerating objects: 31, done.
remote: Counting objects: 100% (31/31), done.
remote: Compressing objects: 100% (29/29), done.
remote: Total 200 (delta 11), reused 8 (delta 2), pack-reused 169
Receiving objects: 100% (200/200), 81.91 KiB | 16.38 MiB/s, done.
Resolving deltas: 100% (86/86), done.
Submodule 'deps/brotli' (https://github.com/google/brotli.git) registered for path 'deps/brotli'
Cloning into '/tmp/tmp.fR4QK184b3/ngx_brotli/deps/brotli'...
Submodule path 'deps/brotli': checked out 'd6d98957ca8ccb1ef45922e978bb10efca0ea541'
ionice: failed to execute ./configure --add-dynamic-module=../ngx_brotli --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module: No such file or directory
checking for OS
 + Linux 5.3.0-1030-aws x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for gcc builtin 64 bit byteswap ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for EPOLLRDHUP ... found
checking for EPOLLEXCLUSIVE ... found
checking for O_PATH ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for prctl(PR_SET_KEEPCAPS) ... found
checking for capabilities ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for nobody group ... not found
checking for nogroup group ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for sched_setaffinity() ... found
checking for SO_SETFIB ... not found
checking for SO_REUSEPORT ... found
checking for SO_ACCEPTFILTER ... not found
checking for SO_BINDANY ... not found
checking for IP_TRANSPARENT ... found
checking for IP_BINDANY ... not found
checking for IP_BIND_ADDRESS_NO_PORT ... found
checking for IP_RECVDSTADDR ... not found
checking for IP_SENDSRCADDR ... not found
checking for IP_PKTINFO ... found
checking for IPV6_RECVPKTINFO ... found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE ... found
checking for TCP_FASTOPEN ... found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for eventfd() ... found
checking for int size ... 4 bytes
checking for long size ... 8 bytes
checking for long long size ... 8 bytes
checking for void * size ... 8 bytes
checking for uint32_t ... found
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... little endian
checking for size_t size ... 8 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 8 bytes
checking for AF_INET6 ... found
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for pwritev() ... found
checking for sys_nerr ... found
checking for localtime_r() ... found
checking for clock_gettime(CLOCK_MONOTONIC) ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for POSIX semaphores ... not found
checking for POSIX semaphores in libpthread ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for sysconf(_SC_LEVEL1_DCACHE_LINESIZE) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
configuring additional dynamic modules
adding module in ../ngx_brotli
 + ngx_brotli was configured
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for zlib library ... found
creating objs/Makefile

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

make -f objs/Makefile modules
make[1]: Entering directory '/tmp/tmp.fR4QK184b3/nginx-1.14.0'
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/common/dictionary.o \
    ../ngx_brotli/deps/brotli/c/common/dictionary.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/common/transform.o \
    ../ngx_brotli/deps/brotli/c/common/transform.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/backward_references.o \
    ../ngx_brotli/deps/brotli/c/enc/backward_references.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/backward_references_hq.o \
    ../ngx_brotli/deps/brotli/c/enc/backward_references_hq.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/bit_cost.o \
    ../ngx_brotli/deps/brotli/c/enc/bit_cost.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/block_splitter.o \
    ../ngx_brotli/deps/brotli/c/enc/block_splitter.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/brotli_bit_stream.o \
    ../ngx_brotli/deps/brotli/c/enc/brotli_bit_stream.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/cluster.o \
    ../ngx_brotli/deps/brotli/c/enc/cluster.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/compress_fragment.o \
    ../ngx_brotli/deps/brotli/c/enc/compress_fragment.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/compress_fragment_two_pass.o \
    ../ngx_brotli/deps/brotli/c/enc/compress_fragment_two_pass.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/dictionary_hash.o \
    ../ngx_brotli/deps/brotli/c/enc/dictionary_hash.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/encode.o \
    ../ngx_brotli/deps/brotli/c/enc/encode.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/encoder_dict.o \
    ../ngx_brotli/deps/brotli/c/enc/encoder_dict.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/entropy_encode.o \
    ../ngx_brotli/deps/brotli/c/enc/entropy_encode.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/histogram.o \
    ../ngx_brotli/deps/brotli/c/enc/histogram.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/literal_cost.o \
    ../ngx_brotli/deps/brotli/c/enc/literal_cost.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/memory.o \
    ../ngx_brotli/deps/brotli/c/enc/memory.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/metablock.o \
    ../ngx_brotli/deps/brotli/c/enc/metablock.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/static_dict.o \
    ../ngx_brotli/deps/brotli/c/enc/static_dict.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/enc/utf8_util.o \
    ../ngx_brotli/deps/brotli/c/enc/utf8_util.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/filter/ngx_http_brotli_filter_module.o \
    ../ngx_brotli/filter/ngx_http_brotli_filter_module.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/ngx_http_brotli_filter_module_modules.o \
    objs/ngx_http_brotli_filter_module_modules.c
cc -o objs/ngx_http_brotli_filter_module.so \
objs/addon/common/dictionary.o \
objs/addon/common/transform.o \
objs/addon/enc/backward_references.o \
objs/addon/enc/backward_references_hq.o \
objs/addon/enc/bit_cost.o \
objs/addon/enc/block_splitter.o \
objs/addon/enc/brotli_bit_stream.o \
objs/addon/enc/cluster.o \
objs/addon/enc/compress_fragment.o \
objs/addon/enc/compress_fragment_two_pass.o \
objs/addon/enc/dictionary_hash.o \
objs/addon/enc/encode.o \
objs/addon/enc/encoder_dict.o \
objs/addon/enc/entropy_encode.o \
objs/addon/enc/histogram.o \
objs/addon/enc/literal_cost.o \
objs/addon/enc/memory.o \
objs/addon/enc/metablock.o \
objs/addon/enc/static_dict.o \
objs/addon/enc/utf8_util.o \
objs/addon/filter/ngx_http_brotli_filter_module.o \
objs/ngx_http_brotli_filter_module_modules.o \
-lm \
-shared
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/addon/static/ngx_http_brotli_static_module.o \
    ../ngx_brotli/static/ngx_http_brotli_static_module.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_brotli/deps/brotli/c/include -I objs -I src/http -I src/http/modules \
    -o objs/ngx_http_brotli_static_module_modules.o \
    objs/ngx_http_brotli_static_module_modules.c
cc -o objs/ngx_http_brotli_static_module.so \
objs/addon/static/ngx_http_brotli_static_module.o \
objs/ngx_http_brotli_static_module_modules.o \
-shared
make[1]: Leaving directory '/tmp/tmp.fR4QK184b3/nginx-1.14.0'

Sucessfully built and installed latest Brotli for NGINX 1.14.0
Modules can be found in /usr/lib/nginx/modules
Next step: Configure dynamic modules and reload/restart NGINX.

################################################################################

root@ip-*.*.*.*:~# nginx -t
nginx: [emerg] module "/usr/share/nginx/modules/ngx_http_brotli_filter_module.so" is not binary compatible in /etc/nginx/nginx.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed

Have checked around but couldn't figure out what's going wrong.

Finally I got it working. These are the steps I followed for below OS's.

Ubuntu 16.* and Ubuntu 18.*
nginx -v 
Note: Nginx version should be above 1.14.* for installing `nginx-module-brotli`
Incase your Nginx version is < 1.14.*, please refer to below link and update it first.

https://medium.com/@soban1193/upgrading-nginx-to-the-latest-version-on-ubuntu-c0ad9116cf87

sudo apt-get install brotli nginx-module-brotli

Over here if you already have it installed and there are some errors while implementing it in nginx, you can remove the package sudo apt-get purge nginx-module-brotli and do a fresh install.

On how to remove your package properly you can refer to this https://askubuntu.com/questions/187888/what-is-the-correct-way-to-completely-remove-an-application

sudo nano /etc/nginx/nginx.conf

nginx.conf

#include /etc/nginx/modules-enabled/*.conf;
user www-data;
worker_processes auto;
pid /run/nginx.pid;

load_module modules/ngx_http_brotli_filter_module.so;
load_module modules/ngx_http_brotli_static_module.so;

 - inside of http block

gzip on;
        gzip_disable "msie6";

         gzip_vary on;
         gzip_proxied any;
         gzip_comp_level 6;
         gzip_buffers 16 8k;
         gzip_http_version 1.1;
         gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;


        brotli on;
        brotli_comp_level 4;
        brotli_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
        brotli_static on;

nginx -t service nginx restart

Done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM