Kenneth Falck's Blog

Silly Nginx Range header problem with Rails

Posted on 2011-05-28 by Kenneth Falck

If your Nginx setup is persistently ignoring the HTTP Range header, make sure your file requests are actually being processed by Nginx.

If you have the typical setup to pass non-existent URLs to Rails, you might be passing the files there by accident, too:

try_files $uri @thin;
location @thin {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://thin_remote;

In my case, the problem was that the web root directory was too protected (mode 700), so Nginx passed all requests to Rails. Rails, in turn, returns the static files from the public directory, but does not support Range requests.

(I couldn't google this, so I wrote it down myself.)