How to configure a simple WebDAV in apache


Decheng (Robbie) Fan

Modify the configuration file httpd.conf.

Firstly, allow loading modules: mod_dav and mod_dav_fs.

Secondly, write a line to create a DAV lock file:

    DavLockDB C:/RobbieTemp/DavLock

If the path contains space, use:

    DavLockDB “C:/Program Files/Apache Group/Apache2

Thirdly, add a <Directory> limiter, and make DAV on inside that directory such as:

<Directory “C:/Program Files/Apache Group/Apache2/htdocs/robbie”>
    Dav On

Make sure the directory is created. Then you can map it as a network drive in Windows 98 and higher versions.

Note that Windows XP map network drive functionality is quite incompatible with Apache WebDAV that almost makes it unusable. In this case, use software NetDrive (free for home use but not free for commercial use) to connect.

Windows Vista can use “map network drive” functionality safely.

After several night’s of research and looking for information online, I found the final answer for Windows XP:

  1. Windows XP, unlike Windows Vista, sends “domainusername” as the user name rather than merely “username”.
  2. Windows XP, by default uses digest authentication, and it doesn’t use basic authentication over unencrypted HTTP.
  3. Apache2.2 WebDAV example configuration file uses digest authentication.
  4. Windows XP can send “username@domain” style user name, thus avoiding the “domainusername” form.
  5. Apache2.2 WebDAV can configure specific users to use the DAV folder.

Summarizing the above, I use this workaround:

  1. Based on the Apache2.2 WebDAV example configuration file, do some modification to point it to the correct folder and use digest authentication.
  2. Use Apache2.2 htdigest tool (mentioned in the WebDAV example configuration file) to create user name and password for a username like username@domain.
  3. In the configuration file, add that user in the <LimitExcept> block to grant read-write access to the user.
  4. Restart Apache2.2.
  5. Try using Windows XP Explorer’s “Map Network Drive” feature to connect to the WebDAV to verify the configuration.

The final configuration for a read-write path that can be accessed by authorized user looks like:

Alias /incoming “E:/web”

<Directory “E:/web”>
    Dav On

    Order Allow,Deny
    Allow from all

    AuthType Digest
    AuthName DAV-upload

    # You can use the htdigest program to create the password database:
    #   htdigest -c “C:/Program Files/Apache Software Foundation/Apache2.2/user.passwd” DAV-upload admin
    AuthUserFile “C:/Program Files/Apache Software Foundation/Apache2.2/user.passwd”
    AuthDigestProvider file

    # Allow universal read-access, but writes are restricted
    # to the admin user.
    <LimitExcept GET OPTIONS>
        require user admin
        require user robbie@localhost

For a read-only path:

Alias /robbiepub “E:/web/public”

<Directory “E:/web/public”>
    Options Indexes
    AllowOverride None
    Order allow,deny
    Allow from all

Notes: Windows XP is unstable with the connection, so don’t use it whenever possible. Vista (supports file timestamps) is better than NetDrive, and NetDrive is better than Windows XP. For Windows 2000 and lower, Web Folders cannot be mapped to a drive letter.

Notes: the 2009 version of NetDrive is not very stable concerning WebDAV access.