Remote read-only storage. NGINX + Furumi

Prerequisites

  • Linux server with data. I use Ubuntu 20.04
  • Linux box as a client. I use Arch Linux

Server setup

Server uses NGINX to index and serve data. Config looks like this:

server {
    listen 80;
    listen [::]:80;
    server_name music;
    root /storage/Torrents/MUS;
    location / {
        include custom/auth.conf;
        autoindex on;
        autoindex_format json;
        try_files $uri $uri/ =404;
    }
}

Client setup

Furumi mount FUSE over HTTP. Get Arch package or binary on Release page. Install FUSE support:

Ubuntu: sudo apt install fuse

Arch: sudo pacman -S fuse

Uncomment user_allow_other in /etc/fuse.conf. Update server and auth in /etc/furumi.yml If using binary release copy Systemd unit manually from latest release. Arch pkg installs everything automatically.

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