# Install Nginx + Webdav on debian 11 > Install Nginx (web server) + Webdav (files on http) on debian 11. Published on 2021-10-21 | Updated on 2025-03-23 | Tags: nginx, webdav https://xsec.fr/en/gnu-linux/nginx-webdav/ --- import Callout from '@shared/components/Callout.astro' import { Collapsible } from '@shared/components/ui/collapsible' import { Steps, Step } from '@/components/ui/steps' If you configure your server directly as root, don't forget to remove `sudo` from each command. If you set a password for the root account, the `sudo` command won't be accepted. Connect directly as root to execute commands. You can also reinstall your system leaving the root password empty during installation. `sudo` will install and work properly. To have the necessary modules, you need to install nginx in its complete version: ```sh sudo apt update && sudo apt install nginx-full ``` - It's done! Your site is accessible in your browser at the address `http://IP_of_your_machine` ## WebDAV configuration Create a configuration file for each site, don't forget to change the port, to avoid having several configurations with the same port. - Here we will edit the default file, but we could very well copy and rename it: ```sh sudo cp /etc/nginx/sites-enabled/default /etc/nginx/sites-enabled/site.conf sudo rm /etc/nginx/sites-enabled/default ``` ## Edit the configuration file ```sh sudo nano /etc/nginx/sites-enabled/site.conf ``` ```sh title="/etc/nginx/sites-enabled/default" server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } location ^~ /webdav { auth_basic "realm_name"; auth_basic_user_file /var/www/.auth.allow; alias /var/www/html; autoindex on; autoindex_exact_size on; autoindex_localtime on; index file.html; dav_methods PUT DELETE MKCOL COPY MOVE; dav_ext_methods PROPFIND OPTIONS; dav_access user:rw; client_body_temp_path /var/www/tmp; client_max_body_size 0; create_full_put_path on; } } ``` - `Ligne 1-3` The server listens on port 80. - `Ligne 5` Defines the path of the root of the internet site (or where your index.html is, for example). - `Ligne 18` `location ^~ /webdav {` says that to reach `/var/www/html` I enter `the ip or the name of my machine` + `/webdav` = `http://172.16.30.30/webdav` for example. - `Ligne 20` Defines the path of the authentication file. ## Create the authentication file ```sh su - ``` Replace `user` by your username: ```sh echo -n 'user:' | tee -a /var/www/.auth.allow ``` Enter your password, confirm, it will be displayed in the form of a hash. ```sh openssl passwd -apr1 | tee -a /var/www/.auth.allow ``` ```sh title="openssl passwd -apr1 | tee -a /var/www/.auth.allow" Password: Verifying - Password: $apr1$t.VOQfZL$bHLajKSa1gA34tgAVWA2l/ ``` Check the user configuration: ```sh cat /var/www/.auth.allow ``` ```sh title="cat /var/www/.auth.allow" user_name:$apr1$9WppBYUH$L4S3jfDRXqfcAJ1mD93KD/ ``` ```sh chown root:www-data /var/www/.auth.allow && chmod 640 /var/www/.auth.allow ``` **Gzip compression is optional and is discouraged if the site uses https.** ```sh sed -i '/gzip_/ s/#\ //g' /etc/nginx/nginx.conf ``` ```sh nginx -t && systemctl restart nginx ``` You can connect to the webdav share (/var/www/html) using the link (http://IP_server/webdav)