Error: 'Invalid Nginx Configuration' when enabling nginx_proxy_brotli in kong.conf

Uses: Kong Gateway
TL;DR

Why do I get an “Invalid Nginx Configuration” error when enabling nginx_proxy_brotli in kong.conf?

This error is typically caused by incorrectly quoting the MIME type values in the nginx_proxy_brotli_types directive. To resolve it, remove the quotes around the MIME type values so the types are listed unquoted. For example, nginx_proxy_brotli_types = text/plain text/css application/json ....

Problem

When configuring nginx_proxy_brotli in kong.conf, you might encounter an error that prevents successful deployment, stating that the nginx configuration is invalid.

Cause

This issue is typically related to how the nginx_proxy_brotli_types directive is formatted in the configuration file. Incorrectly quoting the MIME type values can lead to Nginx configuration errors.

Solution

To resolve this issue, adjust the nginx_proxy_brotli_types directive in your kong.conf file by removing the quotes around the MIME type values.

Here is an example of how to correctly format the nginx_proxy_brotli_types directive in your kong.conf:

nginx_proxy_brotli = on
nginx_proxy_brotli_comp_level = 5
nginx_proxy_brotli_types = text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js

Notice that the MIME types are not enclosed in quotes. This format should prevent the Nginx configuration error.

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!