2013-03-01 33 views
2

我不知道为什么http响应错过了“内容长度标题”当我在nginx中使用gzip时,我真的陷入了困境,请有人帮助我,非常感谢! 这是我的配置文件,使用Nginx + Gzip + Unicorn时缺少内容长度标题

nginx.conf

用户都像做梦; worker_processes 8;

events { 
    worker_connections 1024; 
    accept_mutex on; # "on" if nginx worker_processes > 1 
    use epoll; # enable for Linux 2.6+ 
} 

http { 
    include  mime.types; 
    default_type application/octet-stream; 
    log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 
         '$status $body_bytes_sent "$http_referer" ' 
         '"$http_user_agent" "$http_x_forwarded_for"'; 
    upstream backend-unicorn { 
     server unix:/tmp/unicorn_app.sock fail_timeout=0; 
     #server localhost:5000; 
    } 
    #access_log logs/access.log main; 
    sendfile  on; 
    keepalive_timeout 100; 
    gzip on; 
    gzip_static on; 
    gzip_proxied any; 
    gzip_http_version 1.1; 
    gzip_comp_level 6; 
    gzip_min_length 1100; 
    gzip_buffers 16 8k; 
    gzip_types text/plain application/zip text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript image$ 

    server { 
     listen  8080; 
     server_name misago; 
     access_log /var/log/nginx/unicorn.access.log main; 
     client_max_body_size 64M; 
     location /uploads/ { 
      root /usr/local/rails_apps/me_management_tool/current/public/uploads; 
      break; 
     } 
     error_page 500 502 503 504 /50x.html; 
     location = /50x.html { 
      root html; 
     } 

    } 

} 

回答

3

我不知道为什么HTTP响应错过“Content-Length头”时,我用gzip在nginx的

因为在这种情况下,内容的长度是目前未知发送标题。 Nginx无法知道内容将被压缩的程度。

+0

但是不是没有办法让Nginx在发送gzip响应之前重新计算新的'content-length'吗? – 2017-11-01 16:10:37