Read more

HowTo: Fix nginx not reloading with long gzip_types lines

Marius Schuller
November 11, 2022Software engineer at makandra GmbH

When using many or very long entries of MIME-types that shoudl be gziped in gzip_types directives in nginx you might not be able to successfully reload the service and get this error message instead:

nginx: [emerg] could not build the test_types_hash, you should increase test_types_hash_bucket_size: 64
nginx: configuration file /etc/nginx/nginx.conf test failed

Option 1: Use gzip_types *;

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show snapshot

If you don't care about which MIME type gets the gzip handling, just tell nginx that any MIME type should be gziped.

Especially for assets which might change, this is often the more sensible solution.

Option 2: Add types_hash_bucket_size Show snapshot

If you need to have only very specific, but still very long gzip_types you should just add types_hash_bucket_size Show snapshot to the location that causes the issue and increase it to a value that satisfies your needs.

Posted by Marius Schuller to makandra Operations (2022-11-11 14:29)