Webdav Nginx Ubuntu 16.04

Webdav Nginx Ubuntu 16.04

Introduction to Webdav with Nginx in Ubuntu 16.04

The ever-evolving world of the internet has given us a powerful platform to share information, media, and files for convenient access from almost any location. In such cases, Web Distributed Authoring and Versioning (WebDAV) protocols can be used to provide convenience and user experience. WebDAV is an HTTP-based protocol used for The editing and managing of files stored on remote servers, allowing remote authoring on those files.

Nginx is an open-source web server and reverse proxy for HTTP, SMTP, Pop3 and IMAP protocols. It is being used in production across the majority of the most popular websites today. Nginx is popularly used as a web server for serving static files, and can also be used as a reverse proxy for Apache, Lighttpd, Tomcat and other web applications.

In this tutorial, we will guide you through the steps required to configure WebDAV using Nginx running on Ubuntu 16.04. We will be using the NGNIX package from the official Ubuntu 16.04 repositories.

Pre-Installation Tasks

Before we begin the actual installation of WebDAV and Nginx, we should ensure that all packages are up to date. You can achieve this by running the following command:

$ sudo apt-get update

You will also need to have Nginx installed. If it’s not already installed on your system, you can do so with the following command:

$ sudo apt-get install nginx

…once the Nginx installation is complete, you can verify that Nginx is running by making a request to the server’s public IP address in your web browser. You should see the default Nginx web page with the version number and other information.

Installing WebDAV for Nginx

At this point, we will begin the installation of WebDAV on Nginx. By default, Ubuntu 16.04 ships with WebDAV module available, so you do not need to compile it from source. You can install it by simply running the following command:

$ sudo apt-get install nginx-extras

Once the installation of the nginx-extras package is complete, you can enable WebDAV by including the appropriate module in the Nginx configuration file. To do this, open the main Nginx configuration file and add the following line of code to the end of the file:

include /etc/nginx/conf.d/*.conf;

Now you can create a new configuration file for WebDAV in the /etc/nginx/conf.d/ directory. You can name it dav.conf.

$ sudo vim /etc/nginx/conf.d/dav.conf

Now add the following content to the dav.conf file:

location /dav {
dav_ext_methods PROPFIND OPTIONS;
create_full_put_path on;
dav_access group:rw all:r;

Once you have edited the dav.conf file, save the file and close it. Then, reload the Nginx server for the changes to take effect.

$ sudo systemctl reload nginx

At this point, WebDAV is configured on your Ubuntu 16.04 system.

Configuring WebDAV Authentication

Now that we have installed and enabled WebDAV on our Ubuntu 16.04 system, the next step is to configure authentication for WebDAV. Authentication is required to restrict users to only perform operations such as reading, writing and deleting files on your Ubuntu 16.04 system.

To configure authentication, we will need to create an htpassword file. This is a file that will contain the username and passwords of users that are allowed to access our WebDAV directory. We will be using the htpaswd command, which is distributed as part of the Apache package.

$ sudo apt-get install apache2-utils

Once the installation of the apache2-utils package is complete, you can create the htpassword file with the following command:

$ sudo htpasswd -c /etc/nginx/htpassword demo

When prompted, enter a password for the user and re-confirm it. When you are finished, you will have a password encrypted file named htpassword in the /etc/nginx/ directory. You can view the contents of this file by using the cat command:

$ cat /etc/nginx/htpassword

Now we need to tell Nginx to use this htpassword file for authentication. You can do this by opening your Nginx configuration file and adding the following content to the location /dav block:

auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/htpassword;

The auth_basic option enables HTTP authentication for your website while the auth_basic_user_file specifies the htpassword file you just created. When you are finished, save and close the file, then reload the Nginx server for the changes to take effect.

$ sudo systemctl reload nginx

At this point, authentication is enabled and you will not be allowed to access the WebDAV directory without supplying a valid username and password.

Testing the Configuration

Now that we have configured the WebDAV directory, it’s time to test it out. You can do this by using the cadaver command-line client. This client allows you to connect to a WebDAV server and perform operations such as viewing, deleting, and uploading files.

$ sudo apt-get install cadaver

Once the installation of the cadaver package is complete, you can use it to connect to the WebDAV server by running the following command:

$ cadaver http://server_domain_name_or_IP/dav

You will be prompted to enter the username and password the credentials you created earlier. Once you have authenticated yourself, you will be presented with a cadaver shell. From here, you can run various commands to view, delete, upload or move files.


In this tutorial, we have seen how to install and configure WebDAV and Nginx on Ubuntu 16.04. We have also seen how to enable authentication for the WebDAV directory, and how to test the configuration with the cadaver command-line client. Now, you should be able to configure your own WebDAV server and share files with other users securely.

Thank You for Reading This Article

Thank you for taking the time to read this article. We hope that it has been informative and that it has helped you understand how to install and configure WebDAV with Nginx on Ubuntu 16.04. If you would like to learn more about Linux system administration, please explore other articles in our website.


Q1: Is WebDAV secure?

A1: Yes. WebDAV can be securely configured and it is possible to authenticate users before allowing them to access the shared files.

Q2: How do I configure WebDAV access?

A2: You

Leave a Reply

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