How to configure a WebDAV server using rclone
Introduction
WebDAV is an extension of the HTTP protocol that allows you share files remotely. Most web server software such as Apache HTTPhave built-in WebDAV modules but they usually require complex configuration steps.
One of the easiest ways to configure a WebDAV server is by using rclone.
Rclone is a command line application used to manage files on cloud storage, but it also be used to configure a WebDAV server.
Step 1
Install
rclone.
$ sudo dnf install rclone -yTake a look at the
rclone serve webdavcommand:
rclone serve webdav remote:path [flags]The remote:path specifies the directory for the WebDAV server.
For example:
/media/webdav/We will use the addr, user, and pass flags.
The addr flag is used to specify the IP address and port.
--addr 192.168.4.200:8111The user flag is used to specify a username. Choose a new name that doesn't exist on the server.
--user poochieThe pass flag is the password for the WebDAV user.
--pass myRandomPasswordHere is the full command to start the
WebDAVserver:
$ rclone serve webdav /media/webdav/ --addr 192.168.4.200:8111 --user poochie --pass myRandomPasswordStep 2
Create a custom systemd unit file to control the WebDAV server.
systemd unit file to control the WebDAV server.Create a
bashscript that contains the completerclone servecommand.
$ sudo vi /usr/bin/rclone/rclone_webdav.sh#!/bin/bash
/usr/bin/rclone serve webdav /media/webdav/ --addr 192.168.4.200:8111 --user poochie --pass myRandomPasswordMake the script executable.
$ chmod +X /usr/bin/rclone/rclone_webdav.shCreate a
systemdunit file for the script.
$ vi /etc/systemd/system/rclone_webdav.serviceAdd the following lines:
[Unit]
Description=Rclone WebDAV Service
After=network.target
[Service]
ExecStart=/usr/bin/rclone/rclone_webdav.sh
Restart=always
[Install]
WantedBy=multi-user.targetRun the following
systemctlcommands to start the service:
$ systemctl daemon-reload
$ systemctl start rclone_webdav.service
$ systemctl enable rclone_webdav.serviceVerify the WebDAV server is running:
$ systemctl status rclone_webdav.service