How to setup a CalDAV, CardDAV server with Baikal?

I was looking at several options to self-host my calendar and contacts and one of the most recommended option was doing so via NextCloud. However, seeing as I will probably not have an immediate use for most of the features NextCloud offers, I figure all I needed was just a CalDAV and CardDAV server.

The software I decided to go with is Baïkal. The installation process is straightforward enough and it is compatible with my existing Debian server running Nginx.

  1. Make sure you’ve got all the prerequisites:

    sudo apt install mysql-server php-fpm php-mysql php-sabre-dav
    
  2. Download the latest zip file from their GitHub releases page and unzip it to your desired location (for e.g. /var/www/baikal):

    curl -L https://github.com/sabre-io/Baikal/releases/download/X.X.X/baikal-X.X.X.zip > baikal.zip
    
  3. Allow the Specific directory to be writeable by the webserver:

    sudo chown www-data:www-data /var/www/baikal/Specific
    
  4. Acess the installer by going to the installed location. Follow the instructions to complete the installation and you’re done!

Apache Config

<VirtualHost *:80>

    DocumentRoot /var/www/baikal/html
    ServerName dav.example.org

    RewriteEngine On
    RewriteRule /.well-known/carddav /dav.php [R,L]
    RewriteRule /.well-known/caldav /dav.php [R,L]

    <Directory "/var/www/baikal/html">
        Options None
        Options +FollowSymlinks
        AllowOverride All

        # Confiugration for apache-2.2:
        Order allow,deny
        Allow from all

        # Confiugration for apache-2.4:
        Require all granted
    </Directory>

</VirtualHost>

Nginx Config

server {
  listen       80;
  server_name  dav.example.org;

  root  /var/www/baikal/html;
  index index.php;

  rewrite ^/.well-known/caldav /dav.php redirect;
  rewrite ^/.well-known/carddav /dav.php redirect;

  charset utf-8;

  location ~ /(\.ht|Core|Specific) {
    deny all;
    return 404;
  }

  location ~ ^(.+\.php)(.*)$ {
    try_files $fastcgi_script_name =404;
    include        /etc/nginx/fastcgi_params;
    fastcgi_split_path_info  ^(.+\.php)(.*)$;
    fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  PATH_INFO        $fastcgi_path_info;
  }
}

04 December 2019

index