I have a rails application that serves large static files for registered users. I was able to implement it by following the excellent tutorial here: Secure downloads using nginx, Rails 3.0 and #send_file . Downloading and everything else works fine, but there is only this problem - the header is Content-Lengthnot sent.

This is normal for small files, but downloading large files becomes very unpleasant, as download managers and browsers show no progress. How can i fix this? Should I add something to my configuration nginxor do I need to pass another function to a method send_filein my rails controller? I searched the Internet for quite some time, but to no avail. Please help! Thank!
Here's mine nginx.conf:
upstream unicorn {
server unix:/tmp/unicorn.awesomeapp.sock fail_timeout=0;
}
server {
listen 80 default_server deferred;
root /home/deploy/apps/awesomeapp/current/public;
location ~ /downloads/(.*) {
internal;
alias /home/deploy/uploads/$1;
}
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Sendfile-Type X-Accel-Redirect;
proxy_set_header X-Accel-Mapping /downloads/=/home/deploy/uploads/;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 20M;
keepalive_timeout 10;
}
source
share