Really bizarre problem with Sabredav

Hi everyone,

I’ve been desperately trying to get SabreDav working with Nginx for the
last 3 days almost to no avail. Well, with some success actually. By
following the instructions here:
http://blog.carlkoepke.com/index.php/2011/12/09/nginx-can-do-web-dav-with-a-little-help-from-a-friend/

I can set it up so I can login. I can create folders too. I can’t upload
files though…well, I can’t upload files with file extensions actually,
and it’s this I find really real really bizarre. If I try and upload
blah.blah Transmit returns 405 Not Allowed and in the error logs in
Nginx I get something like “access forbidden by rule” but if I then
upload blah without the extension it works?!?! So i’m mostly getting
lots of 405 Not Allowed’s :frowning:

I’m pretty sure this is an Nginx issue not a Sabredav issue.

Help would be really, really, really appreciated.

Posted at Nginx Forum:

On Thu, 2012-04-19 at 20:01 -0400, squimmy wrote:

blah.blah Transmit returns 405 Not Allowed and in the error logs in
Nginx I get something like “access forbidden by rule” but if I then
upload blah without the extension it works?!?! So i’m mostly getting
lots of 405 Not Allowed’s :frowning:

Without seeing any config or knowing which extensions you refer to, I’m
going to guess that you have a location that matches those extensions
(any chance they are .php?), and that location is handling the PUT
(hence, 405 method not allowed) rather than your DAV location.

Regards,
Cliff

You might try this instead:

Cliff

Hi,

Yeh, I did think about using nginx modules, but that would require
recompiling nginx unless i’m mistaken? I’m also hoping to integrate this
with Owncloud, and that uses SabreDav, so getting that working is my
preferred option.

These are my Nginx conf files:
Nginx.conf: Nginx.conf - Pastebin.com

Virtual.conf: virtual.conf - Pastebin.com

Are there any other conf files that are involved? I’m very new to
Nginx!

Thank you for your help!

Posted at Nginx Forum:

On Sat, 2012-04-21 at 07:49 -0400, squimmy wrote:

Virtual.conf: virtual.conf - Pastebin.com
Here’s what I suspect is happening:

You have location /dav, where I expect is where you want SabreDav to
handle requests. After that you do:

include /usr/local/nginx/conf/php.conf;
include /include /usr/local/nginx/conf/staticfiles.conf;

I suspect these contain regex locations that are matching your
problematic extensions. The reason for this is that these regex
locations will take precedence over your /dav location, so when you do a
DAV request such as “PUT /dav/image.jpg”, you are really doing the PUT
to a regex location such as “~ .(jpg|png|gif)$” in staticfiles.conf or
“~ .php$” in php.conf.

The way Nginx processes requests is outlined here:

http://nginx.org/en/docs/http/request_processing.html

The end result of all of this is you will need to not include your
php.conf and staticfiles.conf as top-level locations. Instead you will
need to include them inside other non-regex locations.

Alternatively, you could setup a subdomain such as dav.domain.com and do
all your DAV requests via that (this is probably the most foolproof).

Regards,
Cliff

On Sat, Apr 21, 2012 at 01:22:29PM -0700, Cliff W. wrote:

On Sat, 2012-04-21 at 07:49 -0400, squimmy wrote:

Hi there,

Here’s what I suspect is happening:

You have location /dav, where I expect is where you want SabreDav to
handle requests.

The way Nginx processes requests is outlined here:

How nginx processes a request

Possibly changing the line

location /dav/

to

location ^~ /dav/

will cause things to Just Work.

But it does depend on what exactly SabreDAV does, and what else is in
your included config files.

If it does work fully, it might be worth sending that information to the
SabreDAV people in case they want to include a “here is how to configure
your web server to use our application” note in their documentation
(assuming that that doesn’t already exist).

Good luck with it,

f

Francis D. [email protected]

Francis, thanks a lot, that seems to have fixed the issue.

I think I need to go through the nginx documentation, seems a little
more intricate and problematic than I first thought.

Posted at Nginx Forum: