← Back to articles

Apache WebDAV setup compatible with Windows

Windows can mount WebDAV shares as drives, but refuses basic auth by default — and getting Apache to serve digest auth that Windows accepts took some troubleshooting. The working setup, documented.

Tedd

Windows supports mounting WebDAV shares as drives. WebDAV is a HTTP protocol for file access used by for example SharePoint.

net use Z: http://server/webdav /PERSISTENT:yes /USER:USER PASS

It does however not support basic auth by default (basic auth sends password in cleartext, which is bad). It took me some troubleshooting to figure it out so I thought I’d share my results. You’ll probably need basic knowledge of setting up and troubleshooting Apache sites as I’ve left out some details. See this tutorial on setting up basic WebDAV. The following builds on this tutorial, but adds digest auth in addition. Note that to mount WebDAV on Windows Server you need Desktop Experience feature installed.

First enable digest auth module:

a2enmod auth_digest

Create the first user:

htdigest -c /var/www/webdav/passwd.dav webdav USER

And edit /etc/apache2/sites-available/default:

NameVirtualHost *
<VirtualHost *>
       ServerAdmin webmaster@localhost
       DocumentRoot /var/www/webdav/mounts
       <Directory /var/www/webdav/mounts>
               Options Indexes MultiViews
               AllowOverride None
               Order allow,deny
               allow from all
       </Directory>

       Alias /webdav /var/www/webdav/mounts

       <Location /webdav>
          DAV On
          DavDepthInfinity on
          #AuthType Basic
          AuthType Digest
          AuthName "webdav"
          AuthUserFile /var/www/webdav/passwd.dav
          AuthDigestDomain /var/www/webdav
          Require valid-user
      </Location>
</VirtualHost> 

Optional: Under the mounts-folder I wanted to share some SMB shares. I also wanted to combine all shared (multiple disks) into a single folder. Note the file_mode and dir_mode if you want write access. You also need standard web permissions on the folders (same as for any website).

//10.0.0.10/pub1 /mnt/pub1 cifs username=XXX,password=XXX,umask=222 0 0
//10.0.0.10/pub2 /mnt/pub2 cifs username=XXX,password=XXX,umask=222 0 0
//10.0.0.10/pub3 /mnt/pub3 cifs username=XXX,password=XXX,umask=222 0 0
//10.0.0.10/pub_rw /var/www/webdav/mounts/pub_rw cifs username=XXX,password=XXX,file_mode=0676,dir_mode=0676,gid=www-data 0 0
mhddfs#/mnt/pub1,/mnt/pub2,/mnt/pub3 /var/www/webdav/mounts/pub fuse defaults,allow_other 0 0 

To combine folders (last line) you need mhddfs installed: apt-get install mhddfs

Written by Tedd · Oslo, Norway

Updated 5 Jan 2017

Follow the journal via RSS