Ryan Detzel

Getting Gzip to Work With Amazon's CloudFront and Nginx

I spent way too much time trying to figure out why CloudFront wouldn’t accept and serve my gzip’d content so I’m posting this hoping that I can save someone else some time.

Instead of diving into the issues with cloudfront and nginx I’ll just provide you with the settings that ended up working for me. The two settings to make note of are the gzip_http_version which is set to 1.0 and the gzip_proxied setting which is set to any. Buffers, comp_level and types can all be changed to fit what you’re trying to serve.

1
2
3
4
5
6
7
gzip on;
gzip_http_version 1.0;
gzip_buffers    4 8k;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 9;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript image/png image/gif image/jpeg;

Comments