InterspaceKnowledgebaseTech ArticlesTutorialsSetup WebDAV Server with Nginx on Linux Debian
Setup WebDAV Server with Nginx on Linux Debian
This guide will help you quickly set up a WebDAV server using Nginx on Debian. It is intended for users with fundamental Linux and Nginx knowledge.

Before you begin, check if Nginx is installed with the ngx_http_dav_module:
nginx -V 2>&1 | grep -o with-http_dav_module

If not present, install Nginx from source or a package that includes this module.

1.WebDAV directory and access credentials

Creating a WebDAV Directory

Create the directory:
sudo mkdir /var/www/webdav

Modify permissions:
sudo chown www-data:www-data /var/www/webdav

Creating a WebDAV User

Configure user access in the webdav.passwd file:

Insert a username:
sudo sh -c "echo -n 'username:' >> /etc/nginx/webdav.passwd"

Set a password:
sudo sh -c "openssl passwd -apr1 >> /etc/nginx/webdav.passwd"

2.Configuring Nginx for WebDAV

In your site-specific Nginx configuration file, typically located in /etc/nginx/sites-available/, within the server block, add:
location /webdav {
root /var/www;
client_body_temp_path /var/tmp/nginx/webdav;
dav_ext_methods PROPFIND OPTIONS;
create_full_put_path on;
dav_access group:rw all:r;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/webdav.passwd;

3.Access Protection (Optional/Recommended)

3.1.IP Restrictions

For IP-based access control, in the location /webdav section of your site-specific Nginx configuration:
allow; # Replace with your IP
deny all;

3.2.Server Tokens Configuration

In your site-specific Nginx configuration file, outside any block, disable server tokens:
server_tokens off;

3.3.Enhancing Security with Headers

Within the server block of your site-specific Nginx configuration, add these security headers:
add_header X-Content-Type-Options "nosniff";
add_header X-XSS-Protection "1; mode=block";
add_header X-Frame-Options "SAMEORIGIN";

3.4.Enhancing Security with SSL/TLS

In your site-specific Nginx configuration file, within the server block, set up SSL/TLS:
listen 443 ssl;
ssl_certificate /path/to/your/certificate.crt;
ssl_certificate_key /path/to/your/private.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'HIGH:!aNULL:!MD5';

4.Setting Up Access and Error Logs

In your site-specific Nginx configuration file, specify logging paths, typically outside of the server block:
access_log /var/log/nginx/webdav_access.log;
error_log /var/log/nginx/webdav_error.log;

5.Applying Changes

Restart Nginx to implement the new settings:
sudo systemctl restart nginx
The content of this document is licensed by Interspace under the MIT License

Related content
My Interspace
Tech Articles
Latest news
Latest events
Related products
Internet Access
Highest-grade Internet access for professional needs. Superior point-to-point fiber-optic link, symmetrical down/up speed, unlimited traffic, SLA 99.9% and static IP. Direct connections to the top tier 1 global providers.

Our network architecture is passionately designed to ensure the highest quality connections to any destination worldwide, boasting unmatched transfer speeds and multi-tier redundancy.

Dedicated Servers
Dedicated servers on high-grade hardware from well-known sever vendors. They are hosted in our own data centers, enabling us full control in safe-guarding the uptime 24/7. Selection of primary data centers and a disaster recovery one located at a safe distance.

Power control options (reset, power off/on) and free of charge KVM-over-IP available 24/7 on a single click, including support to remotely boot/install your own ISO images.
Elastic Cloud VPS
Elastic Cloud VPS is a virtual machine powered by advanced cloud and networking technologies, offering significant advantages over traditional VPS hosting at an unbeatable price to performance ratio.

Deploy OS and apps in just 1 min. Dynamically add or remove features. One click automatic backups, snapshots and disaster recovery replica, stored in a remote data center at a safe distance. New gen of AMD EPYC CPUs, ultra fast NVMe disks, dedicated connections and free private net.

Our website uses cookies. By continuing to use our website, you consent to the use of cookies and you agree with our Terms and conditions.    I understand