Ngx http gzip module

From wikinotes

Documentation

official docs https://nginx.org/en/docs/http/ngx_http_gzip_module.html

Usage

/etc/nginx/nginx.conf

http {
    gzip on;
    gzip_comp_level 9;
    gzip_proxied any;
    gzip_types application/json;

    # ...
}

By default, your payload will still be returned without compression. You'll need to specify that you can accept compression in the header of your request.

curl -i \
    -X GET https://yourdomain/api/blah \
    -H 'Accept-Encoding: gzip'

If everything worked, your reply should be garbled, and content-encoding: gzip should be in the reply's header.

References

https://omgitsmgp.com/2013/09/03/compressing-nginx-json-responses