# Really bizarre problem with Sabredav

**URL:** <https://www.ruby-forum.com/t/really-bizarre-problem-with-sabredav/219073>\
**Category:** NGINX\
**Created:** [April 20, 2012, 2:01am UTC](https://www.ruby-forum.com/t/really-bizarre-problem-with-sabredav/219073 "2012-04-20T02:01:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 20, 2012, 2:01am UTC](https://www.ruby-forum.com/t/really-bizarre-problem-with-sabredav/219073/1 "2012-04-20T02:01:35Z")

</div>

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/](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 ☹

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

Help would be really, really, really appreciated.

Posted at Nginx Forum:

> **[Really bizarre problem with Sabredav](https://forum.nginx.org/read.php?2,225539,225539#msg-225539)**
>
> 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:...

---

<div class="post-metadata">

**Author:** ![squimmy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@squimmy](https://www.ruby-forum.com/u/squimmy)\
**Post date:** [April 20, 2012, 10:06pm UTC](https://www.ruby-forum.com/t/really-bizarre-problem-with-sabredav/219073/2 "2012-04-20T22:06:13Z")

</div>

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 ☹

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

---

<div class="post-metadata">

**Author:** ![squimmy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@squimmy](https://www.ruby-forum.com/u/squimmy)\
**Post date:** [April 20, 2012, 10:14pm UTC](https://www.ruby-forum.com/t/really-bizarre-problem-with-sabredav/219073/3 "2012-04-20T22:14:55Z")

</div>

You might try this instead:

> **[GitHub - arut/nginx-dav-ext-module: nginx WebDAV PROPFIND,OPTIONS,LOCK,UNLOCK...](https://github.com/arut/nginx-dav-ext-module)**
>
> nginx WebDAV PROPFIND,OPTIONS,LOCK,UNLOCK support. Contribute to arut/nginx-dav-ext-module development by creating an account on GitHub.

Cliff

---

<div class="post-metadata">

**Author:** ![squimmy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@squimmy](https://www.ruby-forum.com/u/squimmy)\
**Post date:** [April 21, 2012, 1:49pm UTC](https://www.ruby-forum.com/t/really-bizarre-problem-with-sabredav/219073/4 "2012-04-21T13:49:50Z")

</div>

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](http://pastebin.com/fNPkw4fq)

Virtual.conf: [virtual.conf - Pastebin.com](http://pastebin.com/N4PZXrBm)

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

Thank you for your help!

Posted at Nginx Forum:

> **[Re: Really bizarre problem with Sabredav](https://forum.nginx.org/read.php?2,225539,225589#msg-225589)**
>
> 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:...

---

<div class="post-metadata">

**Author:** ![squimmy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@squimmy](https://www.ruby-forum.com/u/squimmy)\
**Post date:** [April 21, 2012, 10:22pm UTC](https://www.ruby-forum.com/t/really-bizarre-problem-with-sabredav/219073/5 "2012-04-21T22:22:53Z")

</div>

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

> Virtual.conf: [virtual.conf - Pastebin.com](http://pastebin.com/N4PZXrBm)  
> 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:

> **[How nginx processes a request](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](http://dav.domain.com) and do  
all your DAV requests via that (this is probably the most foolproof).

Regards,  
Cliff

---

<div class="post-metadata">

**Author:** ![squimmy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@squimmy](https://www.ruby-forum.com/u/squimmy)\
**Post date:** [April 22, 2012, 12:30am UTC](https://www.ruby-forum.com/t/really-bizarre-problem-with-sabredav/219073/6 "2012-04-22T00:30:59Z")

</div>

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](http://nginx.org/en/docs/http/request_processing.html)

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![squimmy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@squimmy](https://www.ruby-forum.com/u/squimmy)\
**Post date:** [April 25, 2012, 8:46pm UTC](https://www.ruby-forum.com/t/really-bizarre-problem-with-sabredav/219073/7 "2012-04-25T20:46:02Z")

</div>

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:

> **[Re: Really bizarre problem with Sabredav](https://forum.nginx.org/read.php?2,225539,225781#msg-225781)**
>
> 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:...
