SDB:Using webdav

Jump to: navigation, search

Webdav

I want to access my calendar and addressbook from my mainframe and from my notebook. I write exams at the moment so it is the best time to do something else. I've setup a webdav to store my adressbook and calendar so I can access it with KOrganizer, Mozilla Sunbird or KAdressbook from everywhere.

First we have to create a directory for the webdav databases (lock, user).

 mkdir -p /var/lib/apache2/dav
chgrp www /var/lib/apache2/dav
chmod 775 /var/lib/apache2/dav

Now we need a user

 htpasswd2 -c /etc/apache2/dav_users.db username

Change username to your user and enter a password. Now lets create the web accessible directory.

 mkdir /srv/www/webdav
chgrp www /srv/www/webdav
chmod 775 /srv/www/webdav

The next step is to edit the config /etc/sysconfig/apache2 file and add the dav modules add "dav" and "dav_fs". See the example below.

APACHE_MODULES="dav dav_fs"

Of course those two will not the only entry in there you can just add them at the end.

Create a file /etc/apache2/mod_dav.conf with the following content:

<IfModule mod_dav_fs.c>
	# Location of the WebDAV lock database.
	DAVLockDB /var/lib/apache2/dav/lockdb
</IfModule>

<IfModule mod_dav.c>
	# XML request bodies are loaded into memory;
	# limit to 128K by default
	LimitXMLRequestBody 131072
	
	# Location of the WebDav Repository.
	Alias /webdav "/srv/www/webdav"
	
	<Directory /srv/www/webdav>
		# enable webdav for this directory
		DAV On
		Options +Indexes
		IndexOptions FancyIndexing
		AddDefaultCharset UTF-8
		AuthType Basic
		AuthName "WebDAV Server"
		# htpasswd2 -c /etc/apache2/dav_users.db <username>
		AuthUserFile /etc/apache2/dav_users.db
		<LimitExcept GET OPTIONS>
			Require valid-user
		</LimitExcept>
                # needs a2enmod mod_access_compat
		Order allow,deny
		Allow from all
	</Directory>
</IfModule>

Create the file

/etc/apache2/httpd.conf.local

Then put the following line

Include /etc/apache2/mod_dav.conf

Next edit the file /etc/sysconfig/apache2. Look for the entry APACHE_CONF_INCLUDE_FILES and edit it.

APACHE_CONF_INCLUDE_FILES="/etc/apache2/httpd.conf.local"

You need to restart apache2 for 12.x run the command

 systemctl restart apache2.service

For 11.x down run the command

 rcapache2 restart

Now you can access your webdav directory with http://localhost/webdav

You can access it via dolphin, konqueror or nautilus with the following url.

webdav://localhost/webdav


Access it from within your local lan you need to replace the locahost with it's correct ip address.



SSL

I'm sure you want to access your server the secure way, so we need mod_ssl and a certificate. I have an CACert account so I created a real one ;)

You have to create a CSR (Certificate Signing Request) for CACert. This file contains pieces of information about your cert and your public key. It is used by the Certification Authority to sign your cert.
Generate an encrypted key

Type the following command to generate a private key that is file encrypted.

openssl genrsa -des3 -out server.key 1024

You will be prompted for the password to access the file and also when starting your webserver. Warning: If you lose or forget the passphrase, you must generate another certificate. If you decide at a later stage that you would rather use an unencrypted key (cause you don't want to enter the key at boot time), you may create an unencrypted version of server.key in server.key.unsecure by executing:

openssl rsa -in server.key -out server.key.unsecure
Request a Server Certificate

Log in to your CACert account and post the CSR, you'll will receiver the server.crt by mail. Replace the server.key in /etc/apache2/ssl.key and server.crt in /etc/apache2/ssl.crt with your CSR and your cert.
Configure SSL

Edit in /etc/sysconfig/apache2 the add to APACHE_SERVER_FLAGS the option -DSSL. Restart your apache2 and connect e.g. with konqueror to your webdav and log in:

webdavs://localhost/webdav

reference: http://tr.opensuse.org/Webdav (as found using google(...))