Nginx + SabreDAV: Error 405 when accessing location via WebDAV, SabreDAV web interface works without

Dear nginx team,

I’m trying to set up a WebDAV server using SabreDAV.

I successfully set up the server with Apache and now I want to achieve
the
same result with nginx.

Currently, the SabreDAV web GUI works without problems, but access via a
WebDAV client is not possible (I’m using CarotDAV).

Always the error 405 is returned.

I now post my configuration and the debug trace of a request. As no
fastcgi
messages appear, it looks to me as if the problem is caused by nginx,
not a
misconfigured php-fpm interpreter.

server {

                           listen

80;

                           location / {

                                           try_files $uri $uri/

/index.php;

                           }



                           location /TENANT_ID/webdav/ {

                                           try_files $uri $uri/

/TENANT_ID/webdav/index.php?$1;

                           }



                           location ~* (index|fileViewer)\.php$ {

                                           fastcgi_split_path_info

^(.+.php)(/.+)$;

                                           fastcgi_pass

unix:/var/run/php5-fpm.sock;

                                           fastcgi_index index.php;

                                           include fastcgi_params;

                                           fastcgi_param

HTTP_AUTHORIZATION $http_authorization if_not_empty;

                           }

            }

2015/03/13 12:06:44 [debug] 111#0: *513 http request line: “PROPFIND
/TENANT_ID/webdav/ HTTP/1.0”

2015/03/13 12:06:44 [debug] 111#0: *513 http uri: “/TENANT_ID/webdav/”

2015/03/13 12:06:44 [debug] 111#0: *513 http args: “”

2015/03/13 12:06:44 [debug] 111#0: *513 http exten: “”

2015/03/13 12:06:44 [debug] 111#0: *513 posix_memalign:
00000000022D4600:4096 @16

2015/03/13 12:06:44 [debug] 111#0: *513 http process request header line

2015/03/13 12:06:44 [debug] 111#0: *513 http header: “X-Forwarded-Proto:
https”

2015/03/13 12:06:44 [debug] 111#0: *513 http header: “Connection: close”

2015/03/13 12:06:44 [debug] 111#0: *513 http header: “Content-Length: 0”

2015/03/13 12:06:44 [debug] 111#0: *513 http header: “User-Agent:
Rei.Fs.WebDAV/1.11.9”

2015/03/13 12:06:44 [debug] 111#0: *513 http header: “Accept-Encoding:
deflate, gzip”

2015/03/13 12:06:44 [debug] 111#0: *513 http header: “Depth: 1”

2015/03/13 12:06:44 [debug] 111#0: *513 http header done

2015/03/13 12:06:44 [debug] 111#0: *513 event timer del: 3:
1426248464611

2015/03/13 12:06:44 [debug] 111#0: *513 generic phase: 0

2015/03/13 12:06:44 [debug] 111#0: *513 rewrite phase: 1

2015/03/13 12:06:44 [debug] 111#0: *513 test location: “/”

2015/03/13 12:06:44 [debug] 111#0: *513 test location:
“TENANT_ID/webdav/”

2015/03/13 12:06:44 [debug] 111#0: *513 test location: ~
“(index|fileViewer).php$”

2015/03/13 12:06:44 [debug] 111#0: *513 using configuration
“/TENANT_ID/webdav/”

2015/03/13 12:06:44 [debug] 111#0: *513 http cl:0 max:210763776

2015/03/13 12:06:44 [debug] 111#0: *513 rewrite phase: 3

2015/03/13 12:06:44 [debug] 111#0: *513 post rewrite phase: 4

2015/03/13 12:06:44 [debug] 111#0: *513 generic phase: 5

2015/03/13 12:06:44 [debug] 111#0: *513 generic phase: 6

2015/03/13 12:06:44 [debug] 111#0: *513 generic phase: 7

2015/03/13 12:06:44 [debug] 111#0: *513 access phase: 8

2015/03/13 12:06:44 [debug] 111#0: *513 access phase: 9

2015/03/13 12:06:44 [debug] 111#0: *513 post access phase: 10

2015/03/13 12:06:44 [debug] 111#0: *513 try files phase: 11

2015/03/13 12:06:44 [debug] 111#0: *513 http script var:
“/TENANT_ID/webdav/”

2015/03/13 12:06:44 [debug] 111#0: *513 trying to use file:
“/TENANT_ID/webdav/” “/srv/data/TENANT_ID/webdav/”

2015/03/13 12:06:44 [debug] 111#0: *513 http script var:
“/TENANT_ID/webdav/”

2015/03/13 12:06:44 [debug] 111#0: *513 trying to use dir:
“/TENANT_ID/webdav/” “/srv/data/TENANT_ID/webdav/”

2015/03/13 12:06:44 [debug] 111#0: *513 try file uri:
“/TENANT_ID/webdav/”

2015/03/13 12:06:44 [debug] 111#0: *513 content phase: 12

2015/03/13 12:06:44 [debug] 111#0: *513 content phase: 13

2015/03/13 12:06:44 [debug] 111#0: *513 content phase: 14

2015/03/13 12:06:44 [debug] 111#0: *513 content phase: 15

2015/03/13 12:06:44 [debug] 111#0: *513 content phase: 16

2015/03/13 12:06:44 [debug] 111#0: *513 http finalize request: 405,
“/TENANT_ID/webdav/?” a:1, c:1

2015/03/13 12:06:44 [debug] 111#0: *513 http special response: 405,
“/TENANT_ID/webdav/?”

2015/03/13 12:06:44 [debug] 111#0: *513 http set discard body

2015/03/13 12:06:44 [debug] 111#0: *513 xslt filter header

2015/03/13 12:06:44 [debug] 111#0: *513 HTTP/1.1 405 Not Allowed

Server: nginx

Date: Fri, 13 Mar 2015 12:06:44 GMT

Content-Type: text/html

Content-Length: 166

Connection: close

2015/03/13 12:06:44 [debug] 111#0: *513 write new buf t:1 f:0
00000000023121A0, pos 00000000023121A0, size: 145 file: 0, size: 0

2015/03/13 12:06:44 [debug] 111#0: *513 http write filter: l:0 f:0 s:145

2015/03/13 12:06:44 [debug] 111#0: *513 http output filter
“/TENANT_ID/webdav/?”

2015/03/13 12:06:44 [debug] 111#0: *513 http copy filter:
“/TENANT_ID/webdav/?”

2015/03/13 12:06:44 [debug] 111#0: *513 image filter

2015/03/13 12:06:44 [debug] 111#0: *513 xslt filter body

2015/03/13 12:06:44 [debug] 111#0: *513 http postpone filter
“/TENANT_ID/webdav/?” 0000000002312360

2015/03/13 12:06:44 [debug] 111#0: *513 write old buf t:1 f:0
00000000023121A0, pos 00000000023121A0, size: 145 file: 0, size: 0

2015/03/13 12:06:44 [debug] 111#0: *513 write new buf t:0 f:0
0000000000000000, pos 00000000006C5F80, size: 120 file: 0, size: 0

2015/03/13 12:06:44 [debug] 111#0: *513 write new buf t:0 f:0
0000000000000000, pos 00000000006C6700, size: 46 file: 0, size: 0

2015/03/13 12:06:44 [debug] 111#0: *513 http write filter: l:1 f:0 s:311

2015/03/13 12:06:44 [debug] 111#0: *513 http write filter limit 0

2015/03/13 12:06:44 [debug] 111#0: *513 writev: 311

2015/03/13 12:06:44 [debug] 111#0: *513 http write filter
0000000000000000

2015/03/13 12:06:44 [debug] 111#0: *513 http copy filter: 0
“/TENANT_ID/webdav/?”

2015/03/13 12:06:44 [debug] 111#0: *513 http finalize request: 0,
“/TENANT_ID/webdav/?” a:1, c:1

2015/03/13 12:06:44 [debug] 111#0: *513 event timer add: 3:
5000:1426248409611

2015/03/13 12:06:44 [debug] 111#0: *513 http lingering close handler

2015/03/13 12:06:44 [debug] 111#0: *513 recv: fd:3 -1 of 4096

2015/03/13 12:06:44 [debug] 111#0: *513 recv() not ready (11: Resource
temporarily unavailable)

2015/03/13 12:06:44 [debug] 111#0: *513 lingering read: -2

2015/03/13 12:06:44 [debug] 111#0: *513 event timer: 3, old:
1426248409611,
new: 1426248409611

2015/03/13 12:06:44 [debug] 111#0: *513 post event 00007F08EC5301B0

2015/03/13 12:06:44 [debug] 111#0: *513 delete posted event
00007F08EC5301B0

2015/03/13 12:06:44 [debug] 111#0: *513 http lingering close handler

2015/03/13 12:06:44 [debug] 111#0: *513 recv: fd:3 0 of 4096

2015/03/13 12:06:44 [debug] 111#0: *513 lingering read: 0

2015/03/13 12:06:44 [debug] 111#0: *513 http request count:1 blk:0

2015/03/13 12:06:44 [debug] 111#0: *513 http close request

2015/03/13 12:06:44 [debug] 111#0: *513 http log handler

2015/03/13 12:06:44 [debug] 111#0: *513 free: 0000000002311400, unused:
96

2015/03/13 12:06:44 [debug] 111#0: *513 free: 00000000022D4600, unused:
2951

2015/03/13 12:06:44 [debug] 111#0: *513 close http connection: 3

2015/03/13 12:06:44 [debug] 111#0: *513 event timer del: 3:
1426248409611

2015/03/13 12:06:44 [debug] 111#0: *513 reusable connection: 0

2015/03/13 12:06:44 [debug] 111#0: *513 free: 00000000022DB080

2015/03/13 12:06:44 [debug] 111#0: *513 free: 00000000022D2910, unused:
0

2015/03/13 12:06:44 [debug] 111#0: *513 free: 00000000022DAF70, unused:
128

On Fri, Mar 13, 2015 at 01:23:12PM +0100, Sebastian Schwaiger wrote:

Hi there,

I’m trying to set up a WebDAV server using SabreDAV.

I don’t see an obvious sample configuration for this for nginx,
but the sabredav docs do give a sample configuration for apache at
http://sabre.io/dav/webservers/, which seems to indicate that all
requests should be handled by sabredav; so whatever web server is used
is really just there to let sabredav do its work.

That is not what the configuration you show here does; so I suspect
there
may need to be some more discussion about what exactly you want nginx
to do.

I would expect that for nginx, if every request that starts with “/s/”
should be passed to the fastcgi server to be processed by the file
/opt/sabredav/server.php, then all the configuration you need is

server {
location ^~ /s/ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /opt/sabredav/server.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}

That will let requests that do not start with /s/ be served from the
filesystem at /usr/local/nginx/html, or whatever your configured root
is.

                           location /TENANT_ID/webdav/ {

                                           try_files $uri $uri/

/TENANT_ID/webdav/index.php?$1;

$1 there probably does not have what you want.

And the try_files there will probably be what leads to the 405 that you
see…

2015/03/13 12:06:44 [debug] 111#0: *513 http request line: “PROPFIND
/TENANT_ID/webdav/ HTTP/1.0”

…because the request is for /TENANT_ID/webdav/, which refers to a
directory that exists, and the nginx serve-from-the-filesystem handler
does not “do” PROPFIND.

f

Francis D. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs