Calendar server

Preface

Remote calendar applications use CalDav protocol to sync events, it work over HTTP. I use Radicale server.

Prerequisites

  • Linux server with python3-pip, Nginx installed.

Installing

Use pip for fetch Radicale server. Create user for service and grant permissions.

$ sudo python3 -m pip install --upgrade radicale
$ sudo useradd -d /srv/cal/ -c "Radicale server" -U -r radicale 
$ sudo mkdir -p /srv/cal
$ sudo chown -R radicale:radicale /srv/cal

Configuration

Main config file: /etc/radicale/config

[server]
# Bind localhost only
hosts = 127.0.0.1:5232

[auth]
type = None
htpasswd_filename = /path/to/users
htpasswd_encryption = bcrypt
[storage]
filesystem_folder = /srv/cal

I turned off internal auth in favor of Basic Auth in Nginx Proxy.

Simple systemd unit file my be like this: /lib/systemd/system/radical-server.service

[Unit]
Description=Radicale CalDav server for self-hosted calendars.
[Service]
Type=simple
User=radicale
Group=radicale
Restart=always
StartLimitInterval=60s
StartLimitBurst=3
WorkingDirectory=/srv/cal
ExecStart=/usr/bin/python3 -m radicale --config /etc/radicale/config
ExecStop=/usr/bin/killall -TERM /usr/bin/python3 -m radicale --config /etc/radicale/config
[Install]
WantedBy=multi-user.target

Enable and run server:

$ sudo systemctl enable radical-server.service
$ sudo systemctl start radical-server.service

Nginx Proxy Settings

Nginx config file:

server {
    listen 0.0.0.0:80;
    listen [::]:80;

    server_name cal.hexor.ru;

    gzip on;
    gzip_types
      application/javascript
      application/x-javascript
      application/json
      application/rss+xml
      application/xml
      image/svg+xml
      image/x-icon
      application/vnd.ms-fontobject
      application/font-sfnt
      text/css
      text/plain;
    gzip_min_length 256;
    gzip_comp_level 5;
    gzip_http_version 1.1;
    gzip_vary on;

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_pass http://127.0.0.1:5232;
        proxy_redirect off;
        auth_basic           "Administrator’s Area";
        auth_basic_user_file /etc/nginx/.htpasswd;
    }
}

Don’t forget to change server_name and restart Nginx.

How to create /etc/nginx/.htpasswd

Create calendar

Open https://<server_name> in browser using credentials from .htpasswd and create a new calendar.

Setting up Android calendar

I use OpenSync app. Install app and create account like this: app-screenshot

And it works

Leave a Reply

Your email address will not be published.