Before reading this tutorial, please make sure you are using aaPanel to manage Nginx

Download brotli module command

mkdir -p /www/server/ngx_brotli
git clone https://github.com/google/ngx_brotli.git /www/server/ngx_brotli 
cd /www/server/ngx_brotli && git submodule update --init

Install:

  1. If you have already installed Nginx, please uninstall it first
  2. Select compile and install when installing
  3. Paste the above download command into the Prefix script text box
  4. Click Submit then install

Add brotli config to nginx configuration

brotli on; 
brotli_static on; 
brotli_comp_level 11; 
brotli_types text/plain text/css text/xml application/javascript image/x-icon image/svg+xml;

After saving the configuration, your brotli module will officially take effect in Nginx.