SabreDAV on a shared server

1,056 views
Skip to first unread message

Arne Ko

unread,
Jul 24, 2010, 10:39:33 AM7/24/10
to SabreDAV Discussion
Hi there,

I am trying to set up a SabreDAV server on my server - or rather my
hosting service's server.
I keep running into problems, until now all I managed to do was
setting up the server and getting the WebInterface to run, my WebDAV
client does not work, reporting a "Access Forbidden" Error, Charles
says, that I am "out of base uri" which I don't understand. I am
pretty new to php and don't know anything about apache, so I just
"tried" around...

I have a site called mysite.com, I made a folder mysite.com/DAV where
I put the SabreDAV lib folder + a folder "public" + "data"
I put a "index.php" on mysite.com/DAV/

the content of my index.php is

<?php
// !!!! Make sure the Sabre directory is in the include_path !!!
// example:
set_include_path('lib/' . PATH_SEPARATOR . get_include_path());

/*

This is the best starting point if you're just interested in setting
up a fileserver.

Make sure that the 'public' and 'tmpdata' exists, with write
permissions
for your server.

*/

// settings
date_default_timezone_set('Canada/Eastern');
$publicDir = 'public';
$tmpDir = 'data';

// If you want to run the SabreDAV server in a custom location (using
mod_rewrite for instance)
// You can override the baseUri here.
$baseUri = '/DAV/';


// Files we need
require_once 'Sabre/autoload.php';

// Create the root node
$root = new Sabre_DAV_FS_Directory($publicDir);

// The rootnode needs in turn to be passed to the server class
$server = new Sabre_DAV_Server($root);

if (isset($baseUri))
$server->setBaseUri($baseUri);

// Support for LOCK and UNLOCK
$lockBackend = new Sabre_DAV_Locks_Backend_FS($tmpDir);
$lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend);
$server->addPlugin($lockPlugin);

// Support for html frontend
$browser = new Sabre_DAV_Browser_Plugin();
$server->addPlugin($browser);

// Temporary file filter
$tempFF = new Sabre_DAV_TemporaryFileFilterPlugin($tmpDir);
$server->addPlugin($tempFF);

// And off we go!
$server->exec();


?>

This appears to be enough to make the Browser Plugin work, I can
create files and upload/download them. Great.

So I tried mounting it:
dav://mysite.com/DAV/ ->
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:exception>Sabre_DAV_Exception_Forbidden</s:exception>
<s:message>Requested uri (/) is out of base uri (/DAV/)</s:message>
<s:sabredav-version>1.2.4</s:sabredav-version>
</d:error>

and

dav://mysite.com/DAV/index.php/ ->

<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:exception>Sabre_DAV_Exception_Forbidden</s:exception>
<s:message>Requested uri (/) is out of base uri (/DAV/)</s:message>
<s:sabredav-version>1.2.4</s:sabredav-version>
</d:error>

and finally

dav://mysite.com/DAV/public/ ->

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://mysite.com/DAV/
public/">here</a>.</p>
<hr>
<address>Apache/2.2.8 (Linux/SUSE) Server at arne-am-ende.de Port 80</
address>
</body></html>

So there seems to be something wrong with my URIs. I changed the
baseuri to "/" which WORKS, but gives me Access to a folder in
mysite.com/DAV/public/DAV which I created earlier for testing purposes
(don't remember why) and I REALLY don't get why it leads me there.

So I guessed it must have something to do with .htaccess files.

Now, i don't want to pretend, that I understand these. I just copied
them from somewhere here and played around with them:

I put one in
mysite.com/.htaccess containing
RewriteEngine on
RewriteRule ^(.+) /DAV/index.php [L]

and one in
mysite.com/DAV/.htaccess containing

RewriteEngine on
RewriteRule ^(.+) index.php [L]

It would be great if I could get this to work. However, I also didn't
get the digestauth method to work (even though I am fairly confident I
produced the correct .htdigest file, and the calendarplugin wouldn't
let me login with admin admin

Is there even the possibility to make all of thiw work, without having
root access to the server? Almost every solution for related problems
I find here involves some change in apache's configs...

Thanks in advance

Arne

Evert

unread,
Jul 24, 2010, 11:45:19 AM7/24/10
to SabreDAV Discussion
Hi Arne,



On Jul 24, 4:39 pm, Arne Ko <superarn...@googlemail.com> wrote:
> I have a site called mysite.com, I made a folder mysite.com/DAV where
> I put the SabreDAV lib folder + a folder "public" + "data"
> I put a "index.php" on mysite.com/DAV/
>
> the content of my index.php is
> $baseUri = '/DAV/';

This should be correct


>
>
> I put one in
>  mysite.com/.htaccess containing
> RewriteEngine on
> RewriteRule ^(.+) /DAV/index.php [L]
>
> and one in
> mysite.com/DAV/.htaccess containing
>
> RewriteEngine on
> RewriteRule ^(.+) index.php [L]


This is where it's probably going wrong.

If you want to make /DAV/ your root, you only need to place the
htaccess rules in /DAV/.htaccess
The rule you used is incorrect though:

^(.+) means at least one character, what you want is:

RewriteRule (.*) index.php [L]

This will rewrite everything to the index.php file.

One word of caution, older windows WebDAV clients pretty much require
WebDAV to run on the root.
So if you are using Windows XP or Vista (I believe it's fixed in IE7),
then you can't place your server in the /DAV/ subdirectory, and you
simply need to move everything to the root.

There are some 'hacks' to get around that, but let me know how that
goes.

About digest authentication, make sure your 'Realm' is correct. The
sql that produces the admin/admin user/password is based on the realm
being 'SabreDAV'. If the realm is something else, it won't work.

For now just test it without authentication. If that works try to get
Digest auth to work in your browser.

Let me know,
Evert

Arne Ko

unread,
Jul 24, 2010, 2:43:02 PM7/24/10
to SabreDAV Discussion
Ok, so I deleted the /.htaccess and changed the /DAV/.htaccess to
"RewriteEngine on
RewriteRule (/.*) index.php [L]"
but I still get funny error messages:

So, with the configuration above my client tells me, that mysite.com/
DAV/ is not an WEBDAV enabled

When I change the baseurl from "/DAV/" to "DAV/" that message is gone,
but I get a "Forbidden" error, charles says:

<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:exception>Sabre_DAV_Exception_Forbidden</s:exception>
<s:message>Requested uri (/DAV/) is out of base uri (DAV/)</
s:message>
<s:sabredav-version>1.2.4</s:sabredav-version>
</d:error>

Did I forget something else?



Evert

unread,
Jul 27, 2010, 3:24:50 AM7/27/10
to SabreDAV Discussion
I had already sent the following email, but for some reason I don't
see it in the group archive. So I'm just sending it again just in
case:

Evert

unread,
Jul 27, 2010, 3:29:00 AM7/27/10
to SabreDAV Discussion
Ok I copy-pasted the wrong email. Hope it's right this time:

On Sat, Jul 24, 2010 at 8:43 PM, Arne Ko <super...@googlemail.com>
wrote:
> Ok, so I deleted the /.htaccess and changed the /DAV/.htaccess to
> "RewriteEngine on
> RewriteRule (/.*) index.php [L]"

This is still incorrect. Get rid of the /.

> but I still get funny error messages:
>
> So, with the configuration above my client tells me, that mysite.com/
> DAV/ is not an WEBDAV enabled
>

The best way to go about this is to first make sure everything works
from within the browser (use the Sabre_DAV_Browser_Plugin)
Test the main directory and subdirectories as well.

Once that fully works you can start testing a real webdav client.

If you're still getting failures (but it works in the browser) it's
time to fire up a package inspector such as Wireshark and see if you
can find any errors.

But first get those rewriterules correct.

Evert
Reply all
Reply to author
Forward
0 new messages