Question
How do I enable compression for Nginx?
Answer
Gzip is not enabled by default within the Nginx configuration. You will need to enable this by modifying the /etc/nginx/nginx.conf file directly and adding your configuration:
gzip on;
Within the configuration, by default, NGINX compresses responses only with MIME type text/html
. To compress responses with other MIME types, include the gzip_types
directive and list the additional types. For additional mime types, please see MIME types
gzip_types text/plain application/xml;
The overall configuration of gzip compression might look like this.
server {
gzip on;
gzip_types text/plain application/xml;
gzip_proxied no-cache no-store private expired auth;
gzip_min_length 1000;
...
}
Please note your configuration requirements may differ and the above is a general example. For additional information, please review the official Nginx documentation.
Comments
0 comments
Article is closed for comments.