Nginx WebDAV Setup

Overview

Nginx serves as the WebDAV endpoint, providing HTTP-based file access. The configuration creates three server blocks:

  • Port 80 — default HTTP, serves as landing page and Let’s Encrypt challenge endpoint

  • Port 82 — WebDAV without authentication (open access)

  • Port 83 — WebDAV with HTTP Basic authentication

Automatic Installation

The install scripts handle the full Nginx setup:

# Debian
sudo ./install-debian.sh --domain files.example.com --user friendly

# CentOS / RHEL
sudo ./install-centos.sh --domain files.example.com --user friendly

What the Script Does

Debian

  1. Installs nginx, nginx-extras, libnginx-mod-http-dav-ext

  2. Creates /var/www/html/webdav/ directory with proper ownership (www-data)

  3. Deploys Nginx configuration from template

  4. Creates .htpasswd file for authentication

CentOS / RHEL

  1. Adds the official Nginx repository

  2. Installs Nginx from the repository

  3. Downloads Nginx source matching installed version

  4. Compiles ngx_http_dav_ext_module.so as a dynamic module

  5. Loads the module in nginx.conf

  6. Creates /var/www/html/webdav/ directory with proper ownership (nginx)

  7. Deploys Nginx configuration from template

  8. Creates .htpasswd file for authentication

  9. Configures SELinux policies

Nginx Configuration

The configuration template is located at configs/nginx/default.conf.template.

WebDAV Methods

The following WebDAV methods are enabled:

Method Purpose

PUT

Upload files

DELETE

Delete files or directories

MKCOL

Create directories

COPY

Copy files or directories

MOVE

Move/rename files or directories

PROPFIND

List directory contents and file properties

OPTIONS

Query supported methods

Key Directives

create_full_put_path on

Automatically creates intermediate directories when uploading files to nested paths.

client_max_body_size 0

No limit on upload file size.

dav_access user:rw group:rw all:rw

Read/write access for all permission levels.

autoindex on

Enables directory listing in the browser.

Manual Configuration

If you need to modify the Nginx configuration after installation:

Debian
sudo nano /etc/nginx/sites-available/default
sudo nginx -t && sudo systemctl reload nginx
CentOS / RHEL
sudo nano /etc/nginx/conf.d/default.conf
sudo nginx -t && sudo systemctl reload nginx

Verification

Test WebDAV access using a browser or the Filestash WebDAV client:

Or use curl:

# Upload a file (no auth)
curl -T testfile.txt http://files.example.com:82/testfile.txt

# Upload a file (with auth)
curl -u friendly:password -T testfile.txt http://files.example.com:83/testfile.txt

# List files
curl http://files.example.com:82/

# Delete a file
curl -X DELETE http://files.example.com:82/testfile.txt