Learn about Centmin Mod LEMP Stack today
Become a Member

Featured Nginx How to use Brotli compression for Centmin Mod Nginx web servers

Discussion in 'Centmin Mod User Tutorials & Guides' started by eva2000, Mar 6, 2017.

  1. eva2000

    eva2000 Administrator Staff Member

    53,220
    12,114
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,651
    Local Time:
    1:54 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  2. buik

    buik “The best traveler is one without a camera.”

    1,990
    518
    113
    Apr 29, 2016
    Flanders
    Ratings:
    +1,647
    Local Time:
    5:54 AM
    Great .... new browser support but the main problem is more and more the fact that Nginx broti is not maintained anymore. Also no communication what so ever from the creator.

    https://github.com/google/ngx_brotli/issues
     
  3. eva2000

    eva2000 Administrator Staff Member

    53,220
    12,114
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,651
    Local Time:
    1:54 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  4. buik

    buik “The best traveler is one without a camera.”

    1,990
    518
    113
    Apr 29, 2016
    Flanders
    Ratings:
    +1,647
    Local Time:
    5:54 AM

    Nothing against PiotrSikora.
    Very simple.
    If you don't have time don't start a project.
    But that's the most difficult kind of thing for a typical programmer.
    Planning and communicating.
     
  5. upgrade81

    upgrade81 Member

    290
    17
    18
    Sep 5, 2016
    CH
    Ratings:
    +30
    Local Time:
    5:54 AM
    1.17
    10.3
    Which is the best method you use to restart nginx immediately after the overnight update of compressed files?

    I'm using this what do you say?
    Code (Text):
    10 5 * * * /root/tools/brotli/brotli.sh /home/nginx/domains/domainxxx.it/public/wp-content/themes/ "ngxrestart" > /dev/null 2>&1
     
  6. BamaStangGuy

    BamaStangGuy Active Member

    668
    192
    43
    May 25, 2014
    Ratings:
    +272
    Local Time:
    10:54 PM
    Cloudflare now offers this:

    Screenshot 2018-02-23 11.48.30.png
     
  7. eva2000

    eva2000 Administrator Staff Member

    53,220
    12,114
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,651
    Local Time:
    1:54 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    that won't work on command line .. put then in a bash shell script and reference script in cronjob

    but probably not needed as once you enable Centmin Mod ngx_brotli, you can on the fly compress static text files using brotli compression. I do it on thsi forum and on centminmod.com site :)
     
  8. upgrade81

    upgrade81 Member

    290
    17
    18
    Sep 5, 2016
    CH
    Ratings:
    +30
    Local Time:
    5:54 AM
    1.17
    10.3
    I understand, you mean the restart command that does not work, right?

    but I use both on the fly and static files that are still more compressed.
    It works that if it finds the static file skips the process on the fly, correct?
    in this way I take a lot less cpu
     
  9. eva2000

    eva2000 Administrator Staff Member

    53,220
    12,114
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,651
    Local Time:
    1:54 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    you need to separate multiple commands on a single line with semi-column ;

    Code (Text):
    cmd1
    cmd2
    

    would be

    Code (Text):
    cmd1; cmd2
    


    Compression is only done once with static compressed files taken priority over on the fly. And yes static pre-compressed files uses less cpu resources.
     
  10. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    11:54 AM
    Mainline
    10.2
    Why does it needs nginx restart?
     
  11. eva2000

    eva2000 Administrator Staff Member

    53,220
    12,114
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,651
    Local Time:
    1:54 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    To clear any nginx caches.
     
  12. knguyen2015

    knguyen2015 New Member

    11
    1
    3
    Aug 27, 2017
    Ratings:
    +1
    Local Time:
    11:54 PM
    1.12.1
    15.1
    Do I need to disable gzip after enabling Brotli?
     
  13. eva2000

    eva2000 Administrator Staff Member

    53,220
    12,114
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,651
    Local Time:
    1:54 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    no don't disable gzip, not all browsers support brotli so for those browsers nginx will fall back to gzip instead
     
  14. Dnyan

    Dnyan Member

    106
    24
    18
    Sep 16, 2017
    Ratings:
    +36
    Local Time:
    9:24 AM
    1.17.8
    10.3.22
    i get error
    brotil error.jpg

    how i can correct it.

    i also added

    $config['enableGzip'] = false;

    in my src/config.php on xenforo2
     
  15. eva2000

    eva2000 Administrator Staff Member

    53,220
    12,114
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,651
    Local Time:
    1:54 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    did you literally use the same command ? You have to test against a domain url file on your server that is valid replacing the domain.com boostrap.min.css url I used below
    Code (Text):
    curl -sI /dev/null -H"Accept-Encoding: gzip,br" [URL]https://domain.com/brotlitest2/bootstrap.min.css[/URL]
    
     
  16. Dnyan

    Dnyan Member

    106
    24
    18
    Sep 16, 2017
    Ratings:
    +36
    Local Time:
    9:24 AM
    1.17.8
    10.3.22
    i Replaced only domain.com with my domain name and keep rest as it is
     
  17. Dnyan

    Dnyan Member

    106
    24
    18
    Sep 16, 2017
    Ratings:
    +36
    Local Time:
    9:24 AM
    1.17.8
    10.3.22
    I did online testing and found that brotil is working.

    Is this OK or i need to configure something more.

    brotic compression.jpg
     
  18. eva2000

    eva2000 Administrator Staff Member

    53,220
    12,114
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,651
    Local Time:
    1:54 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    need to change url to valid file otherwise you get 404 not found.. but yes online brotli test shows working
     
  19. Dnyan

    Dnyan Member

    106
    24
    18
    Sep 16, 2017
    Ratings:
    +36
    Local Time:
    9:24 AM
    1.17.8
    10.3.22
    I am confuse on what i should change.

    can you please put more lights on it.
     
  20. Nitin

    Nitin New Member

    24
    4
    3
    Apr 30, 2018
    Ratings:
    +4
    Local Time:
    9:24 AM
    Hi, i have enable brotli but my site still keycdn show no brotli. Do i need google pagespeed too. I am new here and dont know much about configuration. I am using vultr 1gb ram vps for running 3 low traffic wordpress blog.

    Checked in chrome also. site address wpseo.ml
    I have done cloudflare authenticated origin pulls correctly. (Doesn't this interfere in renew of letsencrypt certificate). Anything else you want to suggest.

    Code:
    nginx version: nginx/1.13.12
    built by gcc 7.2.1 20170829 (Red Hat 7.2.1-1) (GCC)
    built with OpenSSL 1.1.0h  27 Mar 2018
    TLS SNI support enabled
    configure arguments: --with-ld-opt='-L/usr/local/lib -ljemalloc -Wl,-z,relro -Wl,-rpath,/usr/local/lib' --with-cc-opt='-I/usr/local/include -m64 -march=native -DTCP_FASTOPEN=23 -g -O3 -fstack-protector-strong -flto -fuse-ld=gold --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wimplicit-fallthrough=0 -fcode-hoisting -Wp,-D_FORTIFY_SOURCE=2 -Wno-deprecated-declarations -gsplit-dwarf' --sbin-path=/usr/local/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --with-compat --with-http_stub_status_module --with-http_secure_link_module --with-libatomic --with-http_gzip_static_module --add-dynamic-module=../ngx_brotli --with-http_sub_module --with-http_addition_module --with-http_image_filter_module=dynamic --with-http_geoip_module --with-stream_geoip_module --with-stream_realip_module --with-stream_ssl_preread_module --with-threads --with-stream=dynamic --with-stream_ssl_module --with-http_realip_module --add-dynamic-module=../ngx-fancyindex-0.4.2 --add-module=../ngx_cache_purge-2.4.2 --add-module=../ngx_devel_kit-0.3.0 --add-dynamic-module=../set-misc-nginx-module-0.32 --add-dynamic-module=../echo-nginx-module-0.61 --add-module=../redis2-nginx-module-0.15 --add-module=../ngx_http_redis-0.3.7 --add-module=../memc-nginx-module-0.18 --add-module=../srcache-nginx-module-0.31 --add-dynamic-module=../headers-more-nginx-module-0.33 --with-pcre=../pcre-8.42 --with-pcre-jit --with-zlib=../zlib-cloudflare-1.3.0 --with-http_ssl_module --with-http_v2_module --with-openssl=../openssl-1.1.0h --with-openssl-opt='enable-ec_nistp_64_gcc_128'
    
     
    Last edited: May 12, 2018