Using X-Accel-Redirect when serving a WebDAV file

113 views
Skip to first unread message

Michael Kliewe

unread,
Mar 4, 2015, 6:55:36 AM3/4/15
to sabredav...@googlegroups.com
Hi there,
 
I'm trying to improve the performance of my WebDAV server, and I noticed a problem when downloading big files.
 
I have an nginx as reverse proxy in front of an Apache, on which SabreDAV runs.
 
In SabreDAV I have my App_DAV_File class:
 
public function get()
{
    return fopen($this->getInternalPhysicalPath($this->myPath), 'r');
}
 
This is working fine, but it seems that Apache will send the whole 800 MB file to nginx, and nginx starts to send the file to the client. But it takes a bit (5-10 seconds) until nginx serves the file, and I guess the problem is that the 800 MB have to be read by apache, sent to the nginx, which saves the file to local harddisc. It also adds 800 MB of internal network traffic, from Apache to nginx.
 
I would like to improve that, and use nginx' feature X-Accel-Redirect. Apache should just send the local file path to nginx, and then nginx serves the file. Then there is no 800 MB internal traffic, and I guess the download starts faster.
http://wiki.nginx.org/X-accel
 
How can I do this? I cannot set this HTTP-Header in my App_DAV_File class as far as I can see.
And then I have to check if range-Requests still work correctly if I use X-Accel-Redirect…
 
I'm still running SabreDAV 1.3.4 ;-/ But the same "problem" exists in the current version as far as I can see.
 
(I'm planning to upgrade to 2.0/2.1, it seems to be pretty stable today, but it's a huge step and much work)
 
Michael

Evert Pot

unread,
Mar 4, 2015, 11:44:19 AM3/4/15
to sabredav...@googlegroups.com

There's a 1.3.4 version? Did you mean 1.3.0? That's way old though, oh my. Also has lots of security bugs so I hope you're not using it in production.

Regardless, take a look at this ticket:

https://github.com/fruux/sabre-dav/issues/120

It talks about X-SendFile, but X-Accel-Redirect is similar. The main point is that you are trying to implement this all in a node, where a node should only really be responsible for sharing information about itself.
A separate plugin should take that information and implement the appropriate behavior.

That's why that branch as a node with a getPhysicalPath function, similar to yours:

https://github.com/fruux/sabre-dav/blob/sendfile/lib/Sabre/DAV/IPhysicalFile.php

But has a separate plugin that implements the related behavior:

https://github.com/fruux/sabre-dav/blob/sendfile/lib/Sabre/DAV/XSendFile/Plugin.php#L30

Evert

Reply all
Reply to author
Forward
0 new messages