Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to set Amazon CloudFront up with Nginx using W3 Total Cache and WordPress multisite. CloudFront only works with http 1.0 so, I read that you need to change the http version in gzip to 1.0. I made the change but my headers are still using http 1.1. Here is gzip block:

gzip  on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.0;
gzip_disable "MSIE [1-6].(?!.*SV1)";
gzip_types text/plain text/css application/json application/x-javascript text/xml
                    application/xml application/xml+rss text/javascript;

Here is my complete nginx.conf file:

events {
 worker_connections 5120; # increase for busier servers
 use epoll; # you should use epoll here for Linux kernels 2.6.x
}
http {
 server_name_in_redirect off;
 server_names_hash_max_size 10240;
 server_names_hash_bucket_size 1024;
 include    mime.types;
include    /etc/nginx/fastcgi.conf;
 default_type  application/octet-stream;
 server_tokens off;
# remove/commentout disable_symlinks if_not_owner;if you get Permission denied error
# disable_symlinks if_not_owner;
 sendfile on;

 gzip  on;
 gzip_vary on;
 gzip_proxied any;
 gzip_comp_level 6;
 gzip_buffers 16 8k;
 gzip_http_version 1.0;
 gzip_disable "MSIE [1-6].(?!.*SV1)";
 gzip_types text/plain text/css application/json application/x-javascript text/xml
                        application/xml application/xml+rss text/javascript;

 limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

 tcp_nopush on;
 tcp_nodelay on;
 keepalive_timeout  5;
 ignore_invalid_headers on;
 client_header_timeout  3m;
 client_body_timeout 3m;
 send_timeout     3m;
 reset_timedout_connection on;
 connection_pool_size  256;
 client_header_buffer_size 256k;
 large_client_header_buffers 4 256k;
 client_max_body_size 200M;
 client_body_buffer_size 128k;
 request_pool_size  32k;
 output_buffers   4 32k;
 postpone_output  1460;
 proxy_temp_path  /tmp/nginx_proxy/;
 client_body_in_file_only on;
 log_format bytes_log "$msec $bytes_sent .";
 include "/etc/nginx/vhosts/*";
}

Is there something else I need to change? If I need to provide anymore details please let me know.

Here are the headers.

HTTP/1.1 200 OK => 
Server => nginx admin
Date => Mon, 04 Mar 2013 01:39:33 GMT
Content-Type => text/html; charset=UTF-8
Connection => close
X-Powered-By => PHP/5.3.21
Expires => Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control => no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma => no-cache
X-Pingback => http://website.com/xmlrpc.php
Set-Cookie => PHPSESSID=c593560b5c75dee9b9c1032416ebbd30; path=/
X-Cache => HIT from Backend
share|improve this question
2  
I think you're misunderstanding what you read. You don't have to reduce the version you support just because someone else doesn't support the highest version you support. Also, can you paste the headers that you think are incorrect? You may just be misunderstanding what the option does. (If you literally want to disable HTTP 1.1 support, you can't do it with just a gzip setting.) –  David Schwartz Mar 4 '13 at 0:47
    
Hi David thanks for the info. I added the headers to my original post. –  user715564 Mar 4 '13 at 2:03

1 Answer 1

up vote 0 down vote accepted

Amazon CloudFront sends an HTTP/1.0 request to your origin server, which causes nginx to refuse to send a gzipped response (by default). Setting gzip_http_version 1.0; works around this broken behavior in CloudFront. (It's been 15 years since HTTP/1.1, anything still speaking HTTP/1.0 is fundamentally broken...)

However, once you set it and reload nginx, you also need to invalidate your objects in CloudFront so that new (gzipped) copies will be fetched.

share|improve this answer
    
> you also need to invalidate your objects in CloudFront - That's it. Thanks for the help. –  user715564 Mar 4 '13 at 2:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.