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
-
Installs
nginx,nginx-extras,libnginx-mod-http-dav-ext -
Creates
/var/www/html/webdav/directory with proper ownership (www-data) -
Deploys Nginx configuration from template
-
Creates
.htpasswdfile for authentication
CentOS / RHEL
-
Adds the official Nginx repository
-
Installs Nginx from the repository
-
Downloads Nginx source matching installed version
-
Compiles
ngx_http_dav_ext_module.soas a dynamic module -
Loads the module in
nginx.conf -
Creates
/var/www/html/webdav/directory with proper ownership (nginx) -
Deploys Nginx configuration from template
-
Creates
.htpasswdfile for authentication -
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:
sudo nano /etc/nginx/sites-available/default
sudo nginx -t && sudo systemctl reload nginx
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:
-
Open access:
http://<domain>:82/ -
Authenticated access:
http://<domain>:83/(enter username and password)
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