Difference between revisions of "WebDAV"

From ArchWiki
Jump to: navigation, search
(systemd and style changes)
Line 10: Line 10:
 
== Apache Installation ==
 
== Apache Installation ==
 
{{pkg|apache}} and {{pkg|cadaver}} is needed.
 
{{pkg|apache}} and {{pkg|cadaver}} is needed.
This how to does not cover installation and initial setup of apache.
+
This how to does not cover installation and initial setup of apache. You must [[Daemons#Restarting|restart]] Apache (httpd) after any changes to httpd.conf.
  
 
==WebDav Configuration==
 
==WebDav Configuration==
Line 22: Line 22:
  
 
Next, add the following:
 
Next, add the following:
<pre>
+
{{bc|
 
<Directory "/home/httpd/html/dav">
 
<Directory "/home/httpd/html/dav">
 
   DAV On
 
   DAV On
Line 30: Line 30:
 
   Allow from all
 
   Allow from all
 
</Directory>
 
</Directory>
</pre>
+
}}
  
 
*note: This should also be put in the top level heiracrchy. I put it right before the "UserDir public_html" section, and after the most previous "</Directory>".
 
*note: This should also be put in the top level heiracrchy. I put it right before the "UserDir public_html" section, and after the most previous "</Directory>".
Line 41: Line 41:
  
 
=== Create directories ===
 
=== Create directories ===
<pre>
+
{{bc|
 
(root@box httpd)# mkdir -p /home/httpd/DAV
 
(root@box httpd)# mkdir -p /home/httpd/DAV
 
(root@box httpd)# chown -R http:http /home/httpd/DAV # Otherwise you wouldn't be able to upload files
 
(root@box httpd)# chown -R http:http /home/httpd/DAV # Otherwise you wouldn't be able to upload files
 
(root@box httpd)# mkdir -p /home/httpd/html/dav
 
(root@box httpd)# mkdir -p /home/httpd/html/dav
 
(root@box httpd)# chown -R nobody.nobody /home/httpd/html/dav
 
(root@box httpd)# chown -R nobody.nobody /home/httpd/html/dav
</pre>
+
}}
 
+
=== Restart apache ===
+
# /etc/rc.d/httpd restart
+
  
 
==Test==
 
==Test==
Line 61: Line 58:
 
=== Try to connect ===
 
=== Try to connect ===
 
Note: ipaddress can also be a hostname
 
Note: ipaddress can also be a hostname
<pre>
+
{{bc|
 
(root@box httpd)# cadaver http://ipaddress/dav
 
(root@box httpd)# cadaver http://ipaddress/dav
 
dav:/dav/> mkcol test
 
dav:/dav/> mkcol test
Line 69: Line 66:
 
Coll:  test                                  0  Feb 22 20:31
 
Coll:  test                                  0  Feb 22 20:31
 
dav:/dav/> exit
 
dav:/dav/> exit
</pre>
+
}}
  
 
If the above worked as shown, then you are good to go.
 
If the above worked as shown, then you are good to go.
Line 84: Line 81:
  
 
This is an example for using digest (make sure it is enabled in httpd.conf)
 
This is an example for using digest (make sure it is enabled in httpd.conf)
<pre>
+
{{bc|htdigest -c /etc/httpd/conf/passwd WebDAV foo}}
htdigest -c /etc/httpd/conf/passwd WebDAV foo
+
</pre>
+
  
 
Please make sure that the path is identical to the one you entered in your httpd.conf.  Also when using digest you have to enter the AuthName from httpd.conf.  For plain authentication you would not need this.
 
Please make sure that the path is identical to the one you entered in your httpd.conf.  Also when using digest you have to enter the AuthName from httpd.conf.  For plain authentication you would not need this.
  
 
To require user *foo* for everything:
 
To require user *foo* for everything:
<pre>
+
{{bc|
 
<Directory "/home/httpd/html/dav">
 
<Directory "/home/httpd/html/dav">
 
   DAV On
 
   DAV On
Line 103: Line 98:
 
  Allow from all
 
  Allow from all
 
</Directory>
 
</Directory>
</pre>
+
}}
  
 
If you want to permit everybody to read, you could use this in your httpd.conf
 
If you want to permit everybody to read, you could use this in your httpd.conf
<pre>
+
{{bc|
 
<Directory "/home/httpd/html/dav">
 
<Directory "/home/httpd/html/dav">
 
   DAV On
 
   DAV On
Line 120: Line 115:
 
</LimitExcept>
 
</LimitExcept>
 
</Directory>
 
</Directory>
</pre>
+
}}

Revision as of 04:45, 19 November 2012

WebDAV stands for Web Distributed Authoring and Versionin, see RFC 2518[1].

WebDAV is an extension of the HTTP 1.1 Procotol, therefore can be considered to be a Procotol, and contains a set of concepts and accompanying extension methods to allow read and write across the HTTP 1.1 protocol. Instead of using nfs, or smb, WebDAV offers file transfers via HTTP.

The goal of this how to is to setup webdav with apache. Simple configuration only.

See also File Sharing with Webdav and DNSSD.

Apache Installation

apache and cadaver is needed. This how to does not cover installation and initial setup of apache. You must restart Apache (httpd) after any changes to httpd.conf.

WebDav Configuration

httpd.conf

Edit /etc/httpd/conf/httpd.conf. Add the following line:

DAVLockDB /home/httpd/DAV/DAVLock

Make sure you add it outside of any other directives, at the \"top level\" of the config file heirarchy.

  • note: I put it right under the DocumentRoot definition.

Next, add the following:

<Directory "/home/httpd/html/dav">
  DAV On
  AllowOverride None
  Options Indexes FollowSymLinks
  Order allow,deny
  Allow from all
</Directory>
  • note: This should also be put in the top level heiracrchy. I put it right before the "UserDir public_html" section, and after the most previous "</Directory>".

/srv/http <-> /home/httpd Amendment

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: written in first person. (Discuss in Talk:WebDAV#)

This didn't work out of the box. I'm hoping the original author can figure out how to adjust this tutorial b/c I'm far from an expert. Anyways, I could only connect to my dav folder after putting it below my DocumentRoot. For my fresh installation DocumentRoot "/srv/http" not "/home/httpd/". I'm not unsure if this is the author's choice and old default or completely irrelevant. To sum up, if you use /srv/http instead of /srv/http above (and in other parts of this document) the whole thing works - the rest of my analysis is guesstimation.

Create directories

(root@box httpd)# mkdir -p /home/httpd/DAV
(root@box httpd)# chown -R http:http /home/httpd/DAV # Otherwise you wouldn't be able to upload files
(root@box httpd)# mkdir -p /home/httpd/html/dav
(root@box httpd)# chown -R nobody.nobody /home/httpd/html/dav

Test

Install cadaver

Cadaver is a command line webdav client. It is good for testing. If it is not in a repository, you can download the file manually from my repository and install it, or you can add my repository to your repo list in pacman.conf. For more information about those options check CacTus. Ok. Now back to it..

(root@box httpd)# pacman -S cadaver

Try to connect

Note: ipaddress can also be a hostname

(root@box httpd)# cadaver http://ipaddress/dav
dav:/dav/> mkcol test
Creating `test': succeeded.
dav:/dav/> ls
Listing collection `/dav/': succeeded.
Coll:   test                                   0  Feb 22 20:31
dav:/dav/> exit

If the above worked as shown, then you are good to go.

Make sure you add permissions for viewing and dav access to the directory, and maybe even make that directory ssl access only.

Authentication

Make sure you add permissions for viewing and dav access to the directory, and maybe even make that directory ssl access only.

There are numerous different protocols you can use:

  • plain
  • digest
  • others

This is an example for using digest (make sure it is enabled in httpd.conf)

htdigest -c /etc/httpd/conf/passwd WebDAV foo

Please make sure that the path is identical to the one you entered in your httpd.conf. Also when using digest you have to enter the AuthName from httpd.conf. For plain authentication you would not need this.

To require user *foo* for everything:

<Directory "/home/httpd/html/dav">
  DAV On
  AllowOverride None
  Options Indexes FollowSymLinks
  Order allow,deny
  AuthType Digest
  AuthName "WebDAV"
  AuthUserFile /etc/httpd/conf/passwd
 Require user foo
 Allow from all
</Directory>

If you want to permit everybody to read, you could use this in your httpd.conf

<Directory "/home/httpd/html/dav">
  DAV On
  AllowOverride None
  Options Indexes FollowSymLinks
  Order allow,deny
  AuthType Digest
  AuthName "WebDAV"
  AuthUserFile /etc/httpd/conf/passwd
  Allow from all
<LimitExcept GET HEAD OPTIONS PROPFIND>
 require user foo
</LimitExcept>
</Directory>