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:
- Download Baikal from https://sabre.io/baikal/
- Upload to iRedmail server and unpack into
/opt/www/dav
- Make database and config writable for webserver user
sudo chown -R www-data:www-data /opt/www/dav/Specific
andsudo chown -R www-data:www-data /opt/www/dav/config
- 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.
location ~ ^/dav/(CHANGELOG|INSTALL|LICENSE|README|UPGRADING)($|.*) {
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;
}
}
- 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;
- Restart nginx webserver
sudo service nginx restart
- Modify Baikal configuration with correct URI
sudo nano /opt/www/dav/config/baikal.yaml
. Change base_uri tobase_uri: '/dav/html'
- 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