Difference between revisions of "WebDAV"

From ArchWiki
Jump to: navigation, search
(WebDav Configuration: deleted section that clearly belongs in discussion, not in the actual article.)
(cleanup)
Line 1: Line 1:
 
[[Category:Networking]]
 
[[Category:Networking]]
WebDAV stands for '''Web''' '''D'''istributed '''A'''uthoring and '''V'''ersionin, see RFC 2518[http://www.ietf.org/rfc/rfc2518.txt].  
+
WebDAV stands for '''Web''' '''D'''istributed '''A'''uthoring and '''V'''ersionin, see [http://www.ietf.org/rfc/rfc2518.txt RFC 2518].
  
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.  
+
WebDAV is an extension of HTTP 1.1 and therefore can be considered to be a procotol. It 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 [[Samba|SMB]], WebDAV offers file transfers via HTTP.  
  
The goal of this how to is to setup webdav with apache. Simple configuration only.
+
The goal of this how to is to setup a simple WebDAV configuration using Apache.
  
 
See also [[File Sharing with Webdav and DNSSD]].
 
See also [[File Sharing with Webdav and DNSSD]].
  
== Apache Installation ==
+
== Server (Apache) ==
{{pkg|apache}} and {{pkg|cadaver}} is needed.
+
Install Apache as explained in the [[LAMP]] article.
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==
+
  
 +
Then you will need to confige WebDAV.
 
=== httpd.conf ===
 
=== httpd.conf ===
 
Edit /etc/httpd/conf/httpd.conf. Add the following line:
 
Edit /etc/httpd/conf/httpd.conf. Add the following line:
Line 32: Line 30:
 
}}
 
}}
  
*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 hierarchy. I put it right before the "UserDir public_html" section, and after the most previous "</Directory>".
  
 
=== Create directories ===
 
=== Create directories ===
{{bc|
+
# mkdir -p /home/httpd/DAV
(root@box httpd)# mkdir -p /home/httpd/DAV
+
# 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
+
# mkdir -p /home/httpd/html/dav
(root@box httpd)# mkdir -p /home/httpd/html/dav
+
# chown -R nobody.nobody /home/httpd/html/dav
(root@box httpd)# chown -R nobody.nobody /home/httpd/html/dav
+
}}
+
  
==Test==
+
== Client (Cadaver) ==
=== Install cadaver ===
+
{{Pkg|cadaver}} is a command line WebDAV client.
Cadaver is a command line webdav client. It is good for testing.
+
  # pacman -S cadaver
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 ===
+
=== Test it ===
Note: ipaddress can also be a hostname
+
# cadaver http://localhost/dav
{{bc|
+
dav:/dav/> mkcol test
(root@box httpd)# cadaver http://ipaddress/dav
+
Creating `test': succeeded.
dav:/dav/> mkcol test
+
dav:/dav/> ls
Creating `test': succeeded.
+
Listing collection `/dav/': succeeded.
dav:/dav/> ls
+
Coll: test
Listing collection `/dav/': succeeded.
+
dav:/dav/> exit
Coll:   test                                   0  Feb 22 20:31
+
dav:/dav/> exit
+
}}
+
  
 
If the above worked as shown, then you are good to go.
 
If the above worked as shown, then you are good to go.
 
Make sure you add [[WebDAV_authentication|permissions]] for viewing and dav access to the directory, and maybe even make that directory ssl access only.
 
  
 
== Authentication ==
 
== Authentication ==
Line 75: Line 62:
  
 
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)
{{bc|htdigest -c /etc/httpd/conf/passwd WebDAV foo}}
+
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.
 
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.
Line 89: Line 76:
 
   AuthName "WebDAV"
 
   AuthName "WebDAV"
 
   AuthUserFile /etc/httpd/conf/passwd
 
   AuthUserFile /etc/httpd/conf/passwd
Require user foo
+
  Require user foo
Allow from all
+
  Allow from all
 
</Directory>
 
</Directory>
 
}}
 
}}
Line 105: Line 92:
 
   AuthUserFile /etc/httpd/conf/passwd
 
   AuthUserFile /etc/httpd/conf/passwd
 
   Allow from all
 
   Allow from all
<LimitExcept GET HEAD OPTIONS PROPFIND>
+
  <LimitExcept GET HEAD OPTIONS PROPFIND>
require user foo
+
    require user foo
</LimitExcept>
+
  </LimitExcept>
 
</Directory>
 
</Directory>
 
}}
 
}}
 +
 +
Don't forget to restart apache after making changes!

Revision as of 02:24, 6 January 2013

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

WebDAV is an extension of HTTP 1.1 and therefore can be considered to be a procotol. It 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 a simple WebDAV configuration using Apache.

See also File Sharing with Webdav and DNSSD.

Server (Apache)

Install Apache as explained in the LAMP article.

Then you will need to confige WebDAV.

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 hierarchy. I put it right before the "UserDir public_html" section, and after the most previous "</Directory>".

Create directories

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

Client (Cadaver)

cadaver is a command line WebDAV client.

# pacman -S cadaver

Test it

# cadaver http://localhost/dav
dav:/dav/> mkcol test
Creating `test': succeeded.
dav:/dav/> ls
Listing collection `/dav/': succeeded.
Coll: test
dav:/dav/> exit

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

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>

Don't forget to restart apache after making changes!