Post

Add DAV server to Raspberry Pi

After installing Pi-hole and Vaultwarden (and even a MiniDLNA server) on my Raspberry Pi there were still plenty of resources left. So I decided to add a DAV server to the setup. Until then I was syncing my addressbook and calendar with my email account on Posteo, which I only kept for the DAV capabilities.

Installation

Debian already comes with Radicale in its repositories which also seems like solid choice. We add some additional packages which will come handy later:

1
$ sudo apt install python3-passlib python3-bcrypt apache2-utils radicale

Configuration

Add a user

We will use htpasswd to manage users - for that reason we installed apache2-utils. You can generate the password file basically anywhere, but Radicale’s config directory might be a good choice. We will encrypt the password using bcrypt (hence we installed python3-bcypt):

1
$ sudo htpasswd -B -c /etc/radicale/users <YOUR_USER>

Radicale configuration

You will find a basic configuration file at /etc/radicale/config which is pretty easy to understand. There are a only few things I changed. By the way, when using the Debian package, don’t try to change filesystem_folder, just leave it as is as access to other folders will not be permitted with out editing Radicale’s unit file. You will also need certificates. In case you followed this post, you can simply reuse the certificate and key file. In any case I recommend using your own CA. Copy key and certificate to some place readable by Radicale, i.e.:

1
2
3
4
5
$ sudo mkdir /etc/radicale/certs
$ sudo cp mycert.pem /etc/radicale/certs
$ sudo cp mykey.pem /etc/radicale/certs
$ sudo chmod 640 /etc/radicale/certs/*.pem
$ sudo chgrp radicale /etc/radicale/certs/*.pem

Now go through the config file and check/adjust the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
hosts = <YOUR_RASPBERRYPI_IP>:5232

ssl = True
certificate = /etc/radicale/certs/mycert.pem
key = /etc/radicale/certs/mykey.pem

type = htpasswd
htpasswd_filename = /etc/radicale/users
htpasswd_encryption = bcrypt

type = owner_only

filesystem_folder = /var/lib/radicale/collections

Adjust the firewall:

1
2
$ sudo firewall-cmd --permanent --zone=public --add-port=5232/tcp
$ sudo firewall-cmd --reload

…and finally start Radicale:

1
$ sudo systemctl enable --now radicale

Clients

You can find a list of supported clients here. However, I guess any decent client should be able to connect.

Try to login to the web interface first by going to https://<YOUR_PI_NAME_OR_IP>:5232/ in your browser. Enter the user name and password you selected before. The only thing you can do from here is adding or importing addressbooks and calenders. I was able to import my contacts from Posteo pretty easily, but the calendar failed. It seems there were some invalid field definitions causing this issue. I did not really care as I do not have a lot of stuff in my calendar and just added it later manually via a client.

For Android DAVx5 is the way to go. As the DAV server is not reachable from outside my home network, I configured DAVx5 to sync only when connected to my Wifi network. This will avoid error messages when not at home.

That’s pretty much it. For me this work’s like charm.

Important reminder: you may want to backup your data files located at filesystem_folder (default: /var/lib/radicale/collections) or at least create some exports via your connected clients.

By the way, I also tried running Radicale behind a reverse proxy, but it did not quite work as I did not manage to get DAVx5 to connect to Radicale then. Probably missing some well-known URLs…

This post is licensed under CC BY-SA 4.0 by the author.