Skip to content

Setting Up a WebDAV Server on Ubuntu and Debian

Web Distributed Authoring and Versioning (WebDAV) allows users to collaboratively edit and manage files on remote web servers. This guide will walk you through the installation and configuration of a WebDAV server on Ubuntu and Debian using Apache2.

In this tutorial you will learn:

  • How to install Apache2 and enable WebDAV module
  • How to configure a virtual host for WebDAV
  • How to set up basic and user-authenticated WebDAV directories
  • How to mount a WebDAV directory as part of the local filesystem
Setting Up a WebDAV Server on Ubuntu and Debian
Setting Up a WebDAV Server on Ubuntu and Debian
CategoryRequirements, Conventions or Software Version Used
SystemUbuntu or Debian
SoftwareApache2, WebDAV module
OtherRoot privileges
Conventions# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Overview

This guide will show you how to set up a WebDAV server on Ubuntu or Debian. We will configure the WebDAV server on the example IP address 192.168.122.112. The steps include:

  • Installing Apache2 and Enabling the WebDAV Module: Install Apache2 and enable the WebDAV module to allow WebDAV functionalities on your server.
  • Configuring the Virtual Host: Set up a virtual host to serve the WebDAV directory.
  • Setting Up the WebDAV Directory: Create and configure a directory to store WebDAV data.
  • Adding User Authentication: Secure the WebDAV directory with basic user authentication.
  • Mounting the WebDAV Directory: Mount the WebDAV directory to the local filesystem for easy access.
  • Securing WebDAV with HTTPS: Optionally, secure the WebDAV server with HTTPS using a self-signed certificate or Let’s Encrypt.

Setting up HTTPS and user authentication are optional but recommended for enhanced security.

WEBDAV: BEYOND FILE SHARING
Did you know that WebDAV is not just limited to file sharing and collaboration? WebDAV can also be used to version control documents and manage remote file storage with fine-grained access control. This makes it a versatile tool for managing and editing files directly on a server, supporting complex collaborative environments. Furthermore, WebDAV is extensible, allowing additional features like search, property management, and namespace manipulation, which can be tailored to fit the specific needs of different applications and workflows. For example, WebDAV supports locking mechanisms to prevent editing conflicts, and it can be configured to work over SSL/TLS for secure data transmission, making it a robust solution for sensitive information management. This flexibility is why WebDAV is integrated into many enterprise content management systems and web-based collaborative platforms.

  1. Install Apache2 and Enable WebDAV Module: Begin by installing Apache2 and enabling the WebDAV module.$ sudo apt install apache2Access the default website at http://192.168.122.112. Please note that 192.168.122.112 is an example IP address, and you should use the actual IP address of your server. Disable the default page:$ sudo a2dissite 000-default $ sudo service apache2 reload
  2. Configure Virtual Host: Set up a virtual host for WebDAV.
    Navigate to /etc/apache2/sites-available/ and create a configuration file:$ cd /etc/apache2/sites-available/ $ sudo nano webdav.local.confAdd the following content:<VirtualHost *:80> ServerAdmin webmaster@localhost Servername webdav.local DocumentRoot /var/www/webdav <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/webdav/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> </VirtualHost>Create the /var/www/webdav/ directory, testing index file and set the correct ownership:$ sudo mkdir /var/www/webdav $ sudo sh -c ‘echo “Welcome from WebDAV.local” > /var/www/webdav/index.html’ $ sudo chown www-data:www-data /var/www/webdavEnable the new site and reload Apache2:$ sudo a2ensite webdav.local $ sudo service apache2 reloadTest by navigating to http://192.168.122.112 and you should see “Welcome from WebDAV.local”.This page confirms that Apache Server is up and running.This page confirms that Apache Server is up and running.https://87b035817d4670dd287e616f347ec43b.safeframe.googlesyndication.com/safeframe/1-0-40/html/container.html
  3. Enable WebDAV Module: Enable and configure the WebDAV module.$ sudo a2enmod dav_fsCreate a directory for WebDAV data and some arbitrary data file for testing purposes:$ sudo mkdir /var/www/webdav/svn $ sudo touch /var/www/webdav/svn/linuxconfig.txt $ sudo chown www-data:www-data /var/www/webdav/svnEdit the virtual host configuration /etc/apache2/sites-available/webdav.local.conf to include WebDAV settings:Alias /svn /var/www/webdav/svn <Location /svn> DAV On </Location>Apache configuration file to enable WebDAV server.Apache configuration file to enable WebDAV server.Restart Apache2 to apply changes:$ sudo service apache2 restartTest by navigating to http://192.168.122.112/svn.This page confirms that WebDAV server is enabled correctly. You should be able to see your testing file at this point.This page confirms that WebDAV server is enabled correctly. You should be able to see your testing file at this point.
  4. Set Up User Authentication (optional): Secure the WebDAV directory with user authentication.
    Create a password file and add a user:$ sudo mkdir /usr/local/apache2/ $ sudo htpasswd -c /usr/local/apache2/webdav.passwords linuxconfigSetting up a WebDAV user account.Setting up a WebDAV user account.Edit the virtual host configuration to include authentication settings:<Location /svn> DAV On AuthType Basic AuthName “webdav” AuthUserFile /usr/local/apache2/webdav.passwords Require valid-user </Location>Restart Apache2:$ sudo service apache2 restartWebDAV server now requires correct user authentication.WebDAV server now requires a correct user authentication as configured previously.
  5. Mount WebDAV Directory: Mount the WebDAV directory as part of the local filesystem.
    CONFIGURING DAVFS2 PERMISSIONS
    Configuring davfs2 involves deciding whether to allow non-root (unprivileged) users to mount WebDAV resources. To enable this, the /sbin/mount.davfs file must have the SUID (Set Owner User ID upon execution) bit set, granting necessary permissions. If this option is not selected, only the root user will have the ability to mount WebDAV resources. This configuration can be altered later by running the command dpkg-reconfigure davfs2. The configuration prompt typically provides a choice between allowing or disallowing unprivileged users to mount WebDAV resources, with options to select Yes or No.
    Install davfs2:$ sudo apt install davfs2Create a mount point and mount the directory:$ sudo mkdir /mnt/webdav $ sudo mount.davfs http://192.168.122.112/svn /mnt/webdav/Authenticate and access the mounted directory:$ cd /mnt/webdav/ $ lsOn a client host we can now mount WebDAV file share. On a client host we can now mount WebDAV file share.IMPORTANT CONSIDERATIONS FOR SETTING UP A SECURE WEBDAV SERVER
    When setting up a WebDAV server, be aware of security risks and always implement HTTPS and user authentication to protect your data. Ensure correct file and directory permissions to avoid access issues and configure your firewall to allow necessary traffic. Test compatibility with different clients and monitor server performance, especially with large files or many connections. Regularly back up your data, keep Apache2 and WebDAV modules updated for the latest security patches, and be mindful of the resource usage to maintain a secure and efficient WebDAV server.
  6. Secure WebDAV with HTTPS: To enhance security, it’s advisable to secure your WebDAV directory with HTTPS. This can be done using a self-signed certificate or, preferably, with a certificate from Let’s Encrypt. While configuring a self-signed certificate is a quick solution, using Let’s Encrypt provides a free and automated way to obtain a trusted certificate. For detailed steps on setting up HTTPS with a self-signed certificate, you can refer to our guide on how to enable SSL on the Apache webserver. If you prefer to use Let’s Encrypt, follow the instructions in out Let’s Encrypt SSL articleNote: This step is optional but highly recommended to protect data in transit.

Conclusion

This guide has shown how to set up and configure a WebDAV server on Ubuntu and Debian, covering basic installation, virtual host setup, WebDAV configuration, and user authentication. With this setup, you can collaboratively edit and manage files over the web securely.

Leave a Reply

Your email address will not be published. Required fields are marked *