How to enable response compression using the “gzip” method
How to enable response compression using gzip
How do I enable gzip response compression in Kong?
Inject nginx’s gzip directives (nginx_proxy_gzip, nginx_proxy_gzip_proxied, nginx_proxy_gzip_types) via kong.conf or the equivalent KONG_NGINX_PROXY_GZIP* environment variables (available since Kong EE 0.35; earlier versions need a custom nginx template). Clients must send an Accept-Encoding: gzip header to receive a compressed response.
Steps
It is possible to add the relevant nginx directives to the Kong configuration to enable the features that the nginx module supports.
For example, you could add the following properties to kong.conf or KONG_ environment variables to enable compression for all requests:
nginx_proxy_gzip = on
nginx_proxy_gzip_proxied = any
nginx_proxy_gzip_types = *Or use equivalent environment variables:
KONG_NGINX_PROXY_GZIP=on
KONG_NGINX_PROXY_GZIP_PROXIED=any
KONG_NGINX_PROXY_GZIP_TYPES=*Those are then injected into the proxy server block portion of the template with the nginx_proxy_ part removed.
Only requests which set the Accept-Encoding: gzip header will result in compressed responses. Without this header, the response will be sent uncompressed even after enabling the relevant nginx directives.