Help with X-Accel-Redirect and "rewrite or internal redirection cycle" errors
Iain Barnett
iainspeed at gmail.com
Mon Jun 6 17:48:05 MSD 2011
Thanks for replying.
On 6 Jun 2011, at 14:14, António P. P. Almeida wrote:
>
> Problably your app is issuing redirects for that request.
I thought that with the /files location that the Ruby app wouldn't be touched once it handed off the download?
>
> You should
> issue the X-Accel-Redirect header with the the download location.
>
> X-Accel-Redirect path/to/download/file
>
> Only then will the Ruby handling of the file will be overriden and the
> download handled by Nginx. Cf. http://wiki.nginx.org/NginxXSendfile
>
> --- appa
The Ruby code issues the path so it looks like a uri:
headers( {'X-Accel-Redirect' => "/files/#{title}",
'Content-Type' => "audio/#{File.extname(title)[1..-1]}",
'Content-Disposition' => "attachment",
'Content-Transfer-Encoding' => 'application/octet-stream',
'Content-Length' => File.size( path_to_file ).to_s,
'Cache-Control' => 'no-cache',
'Content-Description' => 'File Transfer', })
Here's an example of an actual header it sends:
D, [Mon 06-06-2011 1439 #82286] DEBUG -- : to_send_to_nginx: {"X-Accel-Redirect"=>"/files/file.m4a", "Content-Type"=>"audio/m4a", "Content-Disposition"=>"attachment", "Content-Transfer-Encoding"=>"application/octet-stream", "Content-Length"=>"9032392", "Cache-Control"=>"no-cache", "Content-Description"=>"File Transfer"}
so with this:
location /files {
internal;
alias /Users/www/sites/$http_host/assets/files;
}
it should end up with Users/www/sites/fakehost.blob/assets/files/file.m4a ?
It seems to be correct for what I've read in the docs and examples - does it look right to you?
Regards,
Iain
More information about the nginx
mailing list