Created
August 30, 2020 14:50
-
-
Save Semdevmaster/700171fe67f88dc9b777a21c04740fae to your computer and use it in GitHub Desktop.
Brotli for NGINX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1) | |
| sudo apt install git gcc cmake libpcre3 libpcre3-dev zlib1g zlib1g-dev openssl libssl-dev | |
| 2) | |
| wget https://nginx.org/download/nginx-<VERSION>.tar.gz | |
| tar zxvf nginx-<VERSION>.tar.gz | |
| 3) | |
| git clone https://github.com/google/ngx_brotli.git | |
| cd ngx_brotli && git submodule update --init | |
| 4) | |
| cd nginx-<VERSION> | |
| sudo ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.19.2/debian/debuild-base/nginx-1.19.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' --with-compat --add-dynamic-module=../ngx_brotli | |
| sudo make modules | |
| 5)COPY .so FILES | |
| sudo cp ./objs/*.so /usr/share/nginx/modules | |
| 6)IN MAIN CONFIG FILE IN HTTP CONTEXT | |
| load_module "modules/ngx_http_brotli_filter_module.so"; | |
| load_module "modules/ngx_http_brotli_static_module.so"; | |
| 7)AND MORE | |
| # Enable Brotli | |
| brotli on; | |
| brotli_static on; | |
| brotli_comp_level 6; | |
| # File types to compress | |
| brotli_types application/atom+xml application/javascript application/json application/rss+xml | |
| application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype | |
| application/x-font-ttf application/x-javascript application/xhtml+xml application/xml | |
| font/eot font/opentype font/otf font/truetype image/svg+xml image/vnd.microsoft.icon | |
| image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment