Learn about Centmin Mod LEMP Stack today
Register Now

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

    35,064
    7,742
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,940
    Local Time:
    9:02 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    • Informative Informative x 1
  2. bassie

    bassie Active Member

    868
    201
    43
    Apr 29, 2016
    Ratings:
    +607
    Local Time:
    1:02 PM
    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

    35,064
    7,742
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,940
    Local Time:
    9:02 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
  4. bassie

    bassie Active Member

    868
    201
    43
    Apr 29, 2016
    Ratings:
    +607
    Local Time:
    1:02 PM

    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 Premium Member Premium Member

    130
    6
    18
    Sep 5, 2016
    Italy
    Ratings:
    +8
    Local Time:
    1:02 PM
    1.13.8
    10
    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

    526
    160
    43
    May 25, 2014
    Ratings:
    +212
    Local Time:
    6:02 AM
    Cloudflare now offers this:

    Screenshot 2018-02-23 11.48.30.png
     
    • Like Like x 1
  7. eva2000

    eva2000 Administrator Staff Member

    35,064
    7,742
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,940
    Local Time:
    9:02 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    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 Premium Member Premium Member

    130
    6
    18
    Sep 5, 2016
    Italy
    Ratings:
    +8
    Local Time:
    1:02 PM
    1.13.8
    10
    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

    35,064
    7,742
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,940
    Local Time:
    9:02 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    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 Premium Member Premium Member

    4,224
    1,027
    113
    May 25, 2014
    Ratings:
    +1,467
    Local Time:
    7:02 PM
    Mainline
    10.2
    Why does it needs nginx restart?
     
  11. eva2000

    eva2000 Administrator Staff Member

    35,064
    7,742
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,940
    Local Time:
    9:02 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    To clear any nginx caches.
     
    • Informative Informative x 1
  12. knguyen2015

    knguyen2015 New Member

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

    eva2000 Administrator Staff Member

    35,064
    7,742
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,940
    Local Time:
    9:02 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    no don't disable gzip, not all browsers support brotli so for those browsers nginx will fall back to gzip instead
     
  14. Dnyan

    Dnyan New Member

    21
    5
    3
    Sep 16, 2017
    Ratings:
    +5
    Local Time:
    4:32 PM
    1.13.5
    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

    35,064
    7,742
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,940
    Local Time:
    9:02 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    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]
    
     
    • Funny Funny x 1
  16. Dnyan

    Dnyan New Member

    21
    5
    3
    Sep 16, 2017
    Ratings:
    +5
    Local Time:
    4:32 PM
    1.13.5
    i Replaced only domain.com with my domain name and keep rest as it is
     
  17. Dnyan

    Dnyan New Member

    21
    5
    3
    Sep 16, 2017
    Ratings:
    +5
    Local Time:
    4:32 PM
    1.13.5
    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

    35,064
    7,742
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,940
    Local Time:
    9:02 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    need to change url to valid file otherwise you get 404 not found.. but yes online brotli test shows working
     
  19. Dnyan

    Dnyan New Member

    21
    5
    3
    Sep 16, 2017
    Ratings:
    +5
    Local Time:
    4:32 PM
    1.13.5
    I am confuse on what i should change.

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

    Nitin New Member

    23
    4
    3
    Apr 30, 2018
    Ratings:
    +4
    Local Time:
    4:32 PM
    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
..