Kjo përmbajtje është e disponueshme vetëm në anglisht. 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.
Your server should already have Linux Debian (version 11 or 12) and Nginx installed from the official Debian repositories. Alternatively, consider our cloud servers offering, known as
Elastic Cloud VPS, which can be deployed with a pre-installed operating system and apps in about a minute.
1.Prerequisites
Before you begin, ensure that you have the
WebDAV module and
nginx-extras package installed.
1.1.Check for the nginx WebDAV module
If you installed Nginx on Debian 11 or 12 using the standard package repositories (e.g., using apt install nginx), the WebDAV module, known as
ngx_http_dav_module, is normally included in the installation. To check, run:
nginx -V 2>&1 | grep -o with-http_dav_module
If the module is not present, you may need to install Nginx from source or use a package that includes this module.
1.2.Install the nginx-extras package
This package contains additional modules not included in the standard Nginx installation, which are necessary for extended WebDAV functionalities. Execute the following command to install it:
sudo apt install nginx-extras
If sudo is not already installed, run
apt install sudo
to install it.
2.WebDAV Directories
Create directories:
sudo mkdir /var/www/webdav
sudo mkdir -p /var/tmp/nginx/webdav
Modify permissions:
sudo chown www-data:www-data /var/www/webdav
sudo chown -R www-data:www-data /var/tmp/nginx
sudo chmod -R 755 /var/tmp/nginx
sudo chmod -R 755 /var/www/webdav
3.WebDAV Access Credentials
To configure user access and set up Basic Authentication, use the following one-liner command. It prompts for a username and password, then securely adds them to the password file
webdav.passwd with the password encrypted.
read -p "Enter username: " username && read -sp "Enter password: " password && echo "$username:$(openssl passwd -apr1 $password)" | sudo tee -a /etc/nginx/webdav.passwd > /dev/null && echo -e "\nCredentials added successfully."
4.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 {
alias /var/www/webdav; # This maps the URL .../webdav to /var/www/webdav
client_body_temp_path /var/tmp/nginx/webdav;
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS;
create_full_put_path on;
# Basic authentication setup
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/webdav.passwd;
# Deny all access unless authenticated
satisfy all;
allow all; # This allows all authenticated users
deny all; # This denies all other users
}
5.Additional Access Protection (Optional)
5.1.IP Restrictions
For IP-based access control, in the
location /webdav section of your site-specific Nginx configuration:
allow 192.168.1.1; # Replace with your IP
deny all;
5.2.Server Tokens Configuration
In your Nginx configuration file disable server tokens:
server_tokens off;
5.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";
6.Applying Changes
Restart Nginx to implement the new settings:
sudo systemctl restart nginx
7.Testing the Setup
To ensure that your WebDAV setup is working correctly, it is recommended to test it using
WinSCP, a free SFTP, FTP, WebDAV, and SCP client for Windows.
Please keep in mind that the built-in Windows WebClient used to map a network drive to a WebDAV location will not work properly, because it requires the LOCK and UNLOCK methods, which are not supported by the native Nginx WebDAV module.
Steps to test with WinSCP- Download WinSCP from the official website and install it.
- Open WinSCP. Click the New Tab button. Select "WebDAV" as the file protocol. Enter your server's URL (e.g., http://your-domain.tld/webdav) and your WebDAV username and password.
- Click "Login" to connect.
- Verify connectivity and WebDAV functionality by navigating through the directories, creating, modifying, and deleting files and folders.
8.Vendosni me Serverët Cloud Interspace
Për ata që kërkojnë të fillojnë shpejt,
Platforma Cloud Interspace ofron një zgjidhje efikase. Ju mund të
vendosni një server virtual me sistem operativ dhe aplikacione të para-instaluara në rreth një minutë. Interspace shkon përtej vendosjes së shpejtë duke ju mundësuar të parakonfiguroni sistemet tuaja me cilësime të personalizuara përpara se të fillojë instalimi. Kjo përfshin vendosjen e detajeve të qasjes, domeneve, porteve për lidhje dhe opsioneve të tjera specifike të aplikacionit.
Përveç vendosjes së shpejtë, Interspace dallohet në raportin çmim-performancë. Ju ftojmë të eksploroni paketat dhe çmimet në faqen për
Elastic Cloud VPS.
Përmbajtja e këtij dokumenti është licencuar nga Interspace nën
Licencën MIT