InterspaceBaza znanjaTehnični člankiVodnikiNastavitev WebDAV strežnika z Nginx na Linux Debian
VODNIKI
15-Jan-202421-Maj-2024
Nastavitev WebDAV strežnika z Nginx na Linux Debian
Ta vsebina je na voljo samo v angleščini.
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.Uvajanje z Interspace oblačnimi strežniki

Za tiste, ki želijo hitro začeti, Interspace oblačna platforma ponuja učinkovito rešitev. Lahko uvedete navidezni strežnik s prednameščenim operacijskim sistemom in aplikacijami v približno eni minuti. Interspace gre še dlje z omogočanjem predkonfiguracije vaših sistemov s prilagojenimi nastavitvami pred začetkom namestitve. To vključuje nastavitev podatkov za dostop, domen, vrat za povezave in drugih možnosti, specifičnih za aplikacije.

Poleg hitrega uvajanja Interspace izstopa po svojem razmerju med ceno in zmogljivostjo. Vabimo vas, da raziščete pakete in cene na strani za Elastic Cloud VPS.
Vsebina tega dokumenta je licencirana s strani Interspace pod MIT licenco

Povezana vsebina
Dokumentacija
Oblak
Komunikacije
Gostovanje
My Interspace
Tehnični članki
Vodniki
Učenje
Novice
Zadnje novice
Zadnji dogodki
Povezani produkti
Premium internetni dostop
Internetni dostop najvišjega razreda za profesionalne potrebe. Vrhunska točka-točka optična povezava, simetrična hitrost prenosa navzdol/navzgor, neomejen promet, SLA 99,9% in statični IP. Neposredne povezave do najboljših globalnih ponudnikov prve stopnje. Naša omrežna arhitektura je skrbno zasnovana za zagotavljanje najvišje kakovosti povezav do katerekoli destinacije po svetu, s hitrostmi prenosa brez primere in večnivojsko redundanco.
Namenski strežniki
Namenski strežniki na vrhunski strojni opremi priznanih proizvajalcev strežnikov. Gostujejo v naših podatkovnih centrih, kar nam omogoča popoln nadzor pri zagotavljanju delovanja 24/7. Izbira primarnih podatkovnih centrov in podatkovnega centra za obnovo po nesreči, ki se nahaja na varni razdalji. Možnosti nadzora napajanja (ponovni zagon, izklop/vklop) in brezplačen KVM-over-IP na voljo 24/7 z enim klikom, vključno s podporo za oddaljeni zagon/namestitev lastnih ISO datotek.
Elastični oblačni VPS
Elastični oblačni VPS je virtualni stroj, ki ga poganjajo napredne oblačne in omrežne tehnologije, ki ponuja pomembne prednosti pred tradicionalnim VPS gostovanjem po nepremagljivem razmerju med ceno in zmogljivostjo. Namestite OS in aplikacije v samo 1 minuti. Dinamično dodajajte ali odstranjujte funkcije. Samodejne varnostne kopije z enim klikom, posnetki in replikacija za obnovo po nesreči, shranjeni v oddaljenem podatkovnem centru na varni razdalji. Nova generacija AMD EPYC procesorjev, izjemno hitri NVMe diski, namenske povezave in brezplačno zasebno omrežje.


Naša spletna stran uporablja piškotke. Z nadaljnjo uporabo naše spletne strani soglašate z uporabo piškotkov in se strinjate z našimi Pogoji uporabe. Razumem