😁 About me 📜 Articles 📚️ Bookshelf 📧 Contact 🎮 Games 🥞 Recipes 📙 Things I use 🔗 Links
🇺🇸 🇵🇱

Webdav setup with nginx on debian

#software #linux #tutorial

2024-01-16

Webdav is a grate way of sharing your folder with multiple devices.

After you setup your nginx server you want to create new "site".

# /etc/nginx/sites-enabled/webdav

server {
    server_name <server name>;
    
    root <path you want to share>;

    location / {
        # Required for proper use of folder manipulation
        if (-d $request_filename) { rewrite ^(.*[^/])$ $1/ break; }
        if ($request_method = MKCOL) { rewrite ^(.*[^/])$ $1/ break; }

        dav_methods PUT DELETE MKCOL COPY MOVE;
        dav_ext_methods PROPFIND OPTIONS;
        dav_access user:rw group:rw all:rw;

        client_max_body_size 0;
        create_full_put_path on;
        client_body_temp_path /tmp/;

        #auth_pam "Restricted";
        #auth_pam_service_name "common-auth";

        auth_basic "Restricted";
        auth_basic_user_file <path with apache2 passwords>

        autoindex on;
    }
}

To enable it run ln -sf /etc/nginx/sites-available/webdav /etc/nginx/sites-enabled/webdav and systemctl restart nginx to restart nginx.