Nginx: disable gzip on images

gzipnginx

In my nginx conf I have which enabled gzip:

gzip on;
gzip_proxied any;
gzip_types text/plain text/css text/javascript;
gzip_comp_level 9;
gzip_vary on;

However this also gzips my jpeg's which actually increases size. How can I, ideally with out using location, disable gzipping of images?

Best Answer

If you didn't set gzip_types image/jpeg anywhere then nginx will never compress your jpegs, unless they have different content-type (like text/plain) in headers.

This may be due to one of the following reasons:

  • You have gzip_types image/jpeg in configuration;
  • Images returned with incorrect content-type header;
  • They compressed by something outside of nginx;
  • A tool that you're using for check is broken.