Deploying WebDAV on Debian 10 using WsgiDAV

Introduction

Web Distributed Authoring and Versioning (WebDAV) is a HTTP extension that provides a framework for remotely creating and modifying files on a server. WsgiDAV is a WebDAV server written in python. This guide will help you through the installation of WsgiDAV version 3.0 on a Vultr server running Debian 10. We will also obtain an SSL certificate to provide a secure connection as well as PAM authentication.

Prerequisites

  • A Debian 10 system to which you have privileged access (via the root user or any sudo user.)
  • The $EDITOR environment variable must be set to a text editor of your choice.
  • A registered domain name is required. Its nameservers must be configured with an A record pointing to your server's IPv4 address, and optionally an AAAA record pointing to the IPv6 address.
  • Familiarity with the YAML syntax is recommended.

The placeholder dav.example.com will be used for your server's domain name.

Installation

SSL certificate

We will start by updating the system and obtaining a free SSL certificate from Let's Encrypt. To do so, first update your system and install the certbot utility:

 sudo apt update
 sudo apt upgrade -y
 sudo apt install -y certbot

In the command below, replace dav.example.com and [email protected] with your domain name and email address respectively before executing it:

sudo certbot certonly --standalone --agree-tos -m [email protected] -d dav.example.com

Your server will be sent a challenge to verify that you control the domain name specified. If it succeeds, the certificate will be issued and saved, along with other files such as the private key, under /etc/letsencrypt/live/dav.example.com/.

Installing WsgiDAV

First, install the python package manager pip:

sudo apt update
sudo apt install -y python3-pip

WsgiDAV requires a HTTP server that supports WSGI. We will install the default option, which is Cheroot. We will also install the lxml python library, which tends to perform better than the XML library installed by default. The PAM (Pluggable Authentication Module) python3 library is needed as well. Install the required packages using the pip tool:

sudo pip3 install wsgidav cheroot lxml python-pam

Configuring WsgiDAV

The WsgiDAV executable is stored in /usr/local/bin, so we will place the configuration file in the /usr/local/etc directory. Download the sample configuration file with the following commands:

sudo mkdir -p /usr/local/etc
sudo wget https://github.com/mar10/wsgidav/raw/master/sample_wsgidav.yaml -O /usr/local/etc/wsgidav.yaml

Open it with your editor:

sudo $EDITOR /usr/local/etc/wsgidav.yaml

Find the following lines in the "SSL Support" section:

# ssl_certificate: "wsgidav/server/sample_bogo_server.crt"
# ssl_private_key: "wsgidav/server/sample_bogo_server.key"
# ssl_certificate_chain: null

Replace them with the following:

ssl_certificate: "/etc/letsencrypt/live/dav.example.com/cert.pem"
ssl_private_key: "/etc/letsencrypt/live/dav.example.com/privkey.pem"
ssl_certificate_chain: "/etc/letsencrypt/live/dav.example.com/chain.pem"

Next, we will configure the share paths by mapping HTTP paths (such as /) to corresponding locations on the filesystem (such as /var/www/dir1). For demonstration purposes, we will share two directories, one of which will be read-only. Find the provider_mapping block in the "SHARES" section:

provider_mapping:
    "/": "/path/to/share1"
    "/pub":
        root: "/path/to/share2"
        readonly: true
    "/share3":
        provider: path.to.CustomDAVProviderClass
        args: ["/path/to/share3", "second_arg"]
        kwargs: {"another_arg": 42}

Replace it:

provider_mapping:
    "/":
    root: "/var/www/html/documents"
    readonly: false
"/reports":
    root: "/var/www/html/reports"
    readonly: true

With these mappings, https://dav.example.com:8080/ will correspond to the /var/www/html/documents directory on the server, while https://dav.example.com:8080/reports will map to /var/www/html/reports with no write access.

For authentication, we will use the PAM driver. This removes the need for separate WebDAV user accounts and allows system users to login using their usual credentials.

In the "AUTHENTICATION" section, find these lines:

accept_basic: true
accept_digest: true
default_to_digest: true
domain_controller: null

Replace them with the following:

accept_basic: true
accept_digest: false
default_to_digest: false
domain_controller: wsgidav.dc.pam_dc.PAMDomainController

You can now test your server:

sudo wsgidav -c /usr/local/etc/wsgidav.yaml

Open https://dav.example.com:8080/ in your web browser. Since we configured PAM authentication, you will need to login with your Linux user account. Use CTRL + C to stop the server before proceeding.

Installing as a service

In order to run your WebDAV server as a system service managed by systemd, create a unit file:

sudo $EDITOR /etc/systemd/system/wsgidav.service

Enter the following:

[Unit]
Description=WsgiDAV WebDAV server
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/wsgidav -c /usr/local/etc/wsgidav.yaml
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=wsgidav_service

[Install]
WantedBy=multi-user.target

Then create a configuration file for the system logging service:

sudo $EDITOR /etc/rsyslog.d/wsgidav_service.conf

Populate the file with the following:

 if $programname == 'wsgidav_service' then /var/log/wsgidav.log
 & stop

Save and exit, then use the commands below to create the log file:

sudo touch /var/log/wsgidav.log
sudo chown root:adm /var/log/wsgidav.log

Finally, load the new systemd unit file and restart the logging service before starting WsgiDAV:

sudo systemctl daemon-reload
sudo systemctl restart rsyslog.service
sudo systemctl start wsgidav.service

You can now use systemctl to start, stop and restart your WebDAV server. WsgiDAV's standard output and error will be logged to /var/log/wsgidav.log, and can also be accessed using sudo journalctl -u wsgidav.service.

If you want the WebDAV server to start automatically at system boot time, execute:

 sudo systemctl enable wsgidav.service

Further reading



Leave a Comment

Configure su propia red privada con OpenVPN

Configure su propia red privada con OpenVPN

Vultr le ofrece una increíble conectividad de red privada para servidores que se ejecutan en la misma ubicación. Pero a veces quieres dos servidores en diferentes países.

Cómo instalar Couch CMS 2.0 en un VPS LAMP Debian 9

Cómo instalar Couch CMS 2.0 en un VPS LAMP Debian 9

¿Usando un sistema diferente? Couch CMS es un sistema de gestión de contenido (CMS) simple y flexible, gratuito y de código abierto que permite a los diseñadores web diseñar

Cómo usar Sudo en Debian, CentOS y FreeBSD

Cómo usar Sudo en Debian, CentOS y FreeBSD

Usar un usuario sudo para acceder a un servidor y ejecutar comandos a nivel raíz es una práctica muy común entre Linux y Unix Systems Administrator. El uso de un sud

Configurar un Chroot en Debian

Configurar un Chroot en Debian

Este artículo le enseñará cómo configurar una cárcel chroot en Debian. Supongo que está utilizando Debian 7.x. Si está ejecutando Debian 6 u 8, esto puede funcionar, pero

How to Install PiVPN on Debian

How to Install PiVPN on Debian

Introduction An easy way to set up a VPN server on Debian is with PiVPN. PiVPN is an installer and wrapper for OpenVPN. It creates simple commands for you t

How to Install Kanboard on Debian 9

How to Install Kanboard on Debian 9

Using a Different System? Introduction Kanboard is a free and open source project management software program which is designed to facilitate and visualiz

How to Install Neos CMS on Debian 9

How to Install Neos CMS on Debian 9

Using a Different System? Neos is a Content Application Platform with a CMS and an application framework at its core. This guide will show you how to instal

Configurar Cactus en Debian Jessie

Configurar Cactus en Debian Jessie

Introducción Cacti es una herramienta de monitoreo y gráficos de código abierto que se basa completamente en datos RRD. A través de Cacti, puedes monitorear casi cualquier tipo de dispositivo

Cómo instalar Java 8 y DCEVM en Debian 8 (Jessie)

Cómo instalar Java 8 y DCEVM en Debian 8 (Jessie)

Java es un lenguaje de programación / máquina virtual independiente de la plataforma. En este tutorial, instalaremos la implementación de OpenJDK de Java 8 en un Debian

Servidor HTTP Git con Nginx en Debian 8

Servidor HTTP Git con Nginx en Debian 8

Git es un sistema de control de versiones (VCS) que permite el seguimiento de cambios en el código. En este tutorial, veremos cómo instalar un servidor HTTP (S) Git, un

Uso de vistas MySQL en Debian 7

Uso de vistas MySQL en Debian 7

Introducción MySQL tiene una gran característica conocida como vistas. Las vistas son consultas almacenadas. Piense en ellos como un alias para una consulta larga. En esta guía,

How to Install Matomo Analytics on Debian 9

How to Install Matomo Analytics on Debian 9

Using a Different System? Matomo (formerly Piwik) is an open source analytics platform, an open alternative to Google Analytics. Matomo source is hosted o

Instale el servidor web Hiawatha con PHP-FPM y MySQL en Debian

Instale el servidor web Hiawatha con PHP-FPM y MySQL en Debian

Hiawatha es un servidor web que tiene en cuenta la simplicidad, la facilidad de uso y la seguridad. Es la solución perfecta para servidores más pequeños, hardware antiguo o incrustación

Monitoree el estado del servidor Debian con Munin

Monitoree el estado del servidor Debian con Munin

Munin es una herramienta de monitoreo para examinar procesos y recursos en su máquina y presenta la información en gráficos a través de una interfaz web. Usa el siguiente

Instale un servidor FTP con ProFTPd en Debian o Ubuntu

Instale un servidor FTP con ProFTPd en Debian o Ubuntu

¿Usando un sistema diferente? En esta guía, veremos cómo configurar un servidor FTP (ProFTPd) para transferir archivos entre su PC y su servidor.

How to Install NodeBB forum on Debian 9

How to Install NodeBB forum on Debian 9

Using a Different System? NodeBB is a Node.js based forum. It utilizes web sockets for instant interactions and real-time notifications. NodeBB source code i

Instalar TaskServer (taskd) en Debian 9

Instalar TaskServer (taskd) en Debian 9

¿Usando un sistema diferente? TaskWarrior es una herramienta de gestión de tiempo de código abierto que es una mejora en la aplicación Todo.txt y sus clones. Debido a th

Upgrading Debian 9 to Debian 10

Upgrading Debian 9 to Debian 10

Introduction Debian 10 (Buster), is the successor to Debian 9 (Stretch). It was released on July 6, 2019. In this tutorial, we will be upgrading an existin

Agregue rango de direcciones IP a su servidor (CentOS / Ubuntu / Debian)

Agregue rango de direcciones IP a su servidor (CentOS / Ubuntu / Debian)

Introducción En este tutorial, cubriremos el proceso de agregar un rango / subred de IP completo a un servidor Linux que ejecuta CentOS, Debian o Ubuntu. El proceso

Instalar Plesk en Debian 8 (Jessie)

Instalar Plesk en Debian 8 (Jessie)

¿Usando un sistema diferente? Plesk es un panel de control de alojamiento web patentado que permite a los usuarios administrar sus sitios web y bases de datos personales y / o de clientes

ZPanel y Sentora en CentOS 6 x64

ZPanel y Sentora en CentOS 6 x64

ZPanel, un panel de control de alojamiento web popular, se bifurcó en 2014 a un nuevo proyecto llamado Sentora. Aprende a instalar Sentora en tu servidor con este tutorial.

Cómo instalar Vtiger CRM Open Source Edition en CentOS 7

Cómo instalar Vtiger CRM Open Source Edition en CentOS 7

Aprende cómo instalar Vtiger CRM, una aplicación de gestión de relaciones con el cliente, en CentOS 7 para aumentar tus ventas y mejorar el servicio al cliente.

Cómo instalar el servidor Counter-Strike 1.6 en Linux

Cómo instalar el servidor Counter-Strike 1.6 en Linux

Esta guía completa le mostrará cómo configurar un servidor Counter-Strike 1.6 en Linux, optimizando el rendimiento y la seguridad para el mejor juego. Aprende los pasos más recientes aquí.

¿Puede la IA luchar con un número cada vez mayor de ataques de ransomware?

¿Puede la IA luchar con un número cada vez mayor de ataques de ransomware?

Los ataques de ransomware van en aumento, pero ¿puede la IA ayudar a lidiar con el último virus informático? ¿Es la IA la respuesta? Lea aquí, sepa que la IA es una bendición o una perdición

ReactOS: ¿Es este el futuro de Windows?

ReactOS: ¿Es este el futuro de Windows?

ReactOS, un sistema operativo de código abierto y gratuito, está aquí con la última versión. ¿Puede satisfacer las necesidades de los usuarios de Windows de hoy en día y acabar con Microsoft? Averigüemos más sobre este estilo antiguo, pero una experiencia de sistema operativo más nueva.

Manténgase conectado a través de la aplicación de escritorio WhatsApp 24 * 7

Manténgase conectado a través de la aplicación de escritorio WhatsApp 24 * 7

Whatsapp finalmente lanzó la aplicación de escritorio para usuarios de Mac y Windows. Ahora puede acceder a Whatsapp desde Windows o Mac fácilmente. Disponible para Windows 8+ y Mac OS 10.9+

¿Cómo puede la IA llevar la automatización de procesos al siguiente nivel?

¿Cómo puede la IA llevar la automatización de procesos al siguiente nivel?

Lea esto para saber cómo la Inteligencia Artificial se está volviendo popular entre las empresas de pequeña escala y cómo está aumentando las probabilidades de hacerlas crecer y dar ventaja a sus competidores.

La actualización complementaria de macOS Catalina 10.15.4 está causando más problemas que resolver

La actualización complementaria de macOS Catalina 10.15.4 está causando más problemas que resolver

Recientemente, Apple lanzó macOS Catalina 10.15.4, una actualización complementaria para solucionar problemas, pero parece que la actualización está causando más problemas que conducen al bloqueo de las máquinas Mac. Lee este artículo para obtener más información

13 Herramientas comerciales de extracción de datos de Big Data

13 Herramientas comerciales de extracción de datos de Big Data

13 Herramientas comerciales de extracción de datos de Big Data

¿Qué es un sistema de archivos de diario y cómo funciona?

¿Qué es un sistema de archivos de diario y cómo funciona?

Nuestra computadora almacena todos los datos de una manera organizada conocida como sistema de archivos de diario. Es un método eficiente que permite a la computadora buscar y mostrar archivos tan pronto como presiona buscar.