Mictronics - DIY Electronic projects and more.

Baikal server on iRedmail installation with Nginx

I was fiddling two days getting the Baikal DAV server running on a fresh iRedmail installation using the Nginx webserver. Finally, solved the Nginx configuration issues and got it working. Here is a step by step howto.

Prerequisit: iRedmail installed and configured on a fresh system. I used Ubuntu Server 22.04 LTS full installation, not minimized.

Baikal installation:

  1. Download Baikal from https://sabre.io/baikal/
  2. Upload to iRedmail server and unpack into /opt/www/dav
  3. Make database and config writable for webserver user sudo chown -R www-data:www-data /opt/www/dav/Specific and sudo chown -R www-data:www-data /opt/www/dav/config
  4. Create Baikal configuration template for nginx sudo nano /etc/nginx/templates/baikal.tmpl. Add content:
# Running Baikal as a subfolder on an existing virtual host
# Block access to default directories and files under these directories
location ~ ^/dav/(\.ht|Core|Specific|config)($|.*) {
    deny all;
    return 404;

# Block access to default files under top-directory and files start with same name.
    deny all;
    return 404;

location ~ ^/dav/(.*) {
    root /opt/www;
    index index.php;
    rewrite ^/dav/.well-known/caldav /dav/dav.php redirect;
    rewrite ^/dav/.well-known/carddav /dav/dav.php redirect;
    rewrite ^/caldav /dav/dav.php redirect;
    rewrite ^/carddav /dav/dav.php redirect;

    location ~ ^(.+\.php)(.*)$ {
       alias /opt/www;
       include /etc/nginx/templates/hsts.tmpl;
       include /etc/nginx/templates/fastcgi_php.tmpl;
       fastcgi_split_path_info ^(.+\.php)(.*)$;
       fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
       fastcgi_param  PATH_INFO  $fastcgi_path_info;
  1. Modify available sites configuration sudo nano /etc/nginx/sites-available/00-default-ssl.conf.
    include /etc/nginx/templates/netdata.tmpl;
    include /etc/nginx/templates/baikal.tmpl; <-- Add template
    include /etc/nginx/templates/php-catchall.tmpl;
  1. Restart nginx webserver sudo service nginx restart
  2. Modify Baikal configuration with correct URI sudo nano /opt/www/dav/config/baikal.yaml. Change base_uri to base_uri: '/dav/html'
  3. Access the Baikal installer by browsing to https://yourserver.example.org/dav/html/

The DAV client URL looks like this https://yourserver.example.org/dav/html/dav.php

👈 Home