nerds:~ #

27Jan/102

Setup WebDAV in Apache2 on SuSE Linux to Support Windows (XP/Vista/7) Clients

Earlier today, a colleague told me that she doesn't like using my servers because I don't have FTP setup thus, she couldn't map my server as a drive. Well, I showed her. I stand firmly against using FTP as any type of web-related solution and thus, decided on WebDAV to address my colleague's demanding needs.

Initially, I set the virtual host up for Basic Authentication but was unable to get Windows 7 and Windows XP to map the drive. Windows complained that "The network path could not be found." I tried mapping the drive from both the command line and from Windows Explorer with no luck. Then I read that theWindows webDAV client does not support Basic Authentication. If this server were on my domain, I'd use Kerberos without a second thought, but it's an Internet web server so that is out of the question. Digest Authentication it is.

I went enable mod_dav, mod_dav_fs, and mod_auth_digest in YaST under Network Services >> HTTP Server >> Server Modules and I restarted the service. I then created the folder /var/davlock, gave it the proper permissions and added the following to httpd.conf

<Ifmodule mod_dav.c>
  DAVLockDB /var/davlock/DAVlock
</IfModule>


Then I added the new host, sample.acme.com to my vhosts.conf file and restarted the service.

<VirtualHost *:80>
    ServerAdmin nobody@localhost
    ServerName sample.acme.com
    DocumentRoot /www/wordpress/sample
    ErrorLog /var/log/apache2/sample-error_log
    CustomLog /var/log/apache2/sample-access_log combined
    UseCanonicalName Off

<Directory "/www/wordpress/sample">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
DAV On

#Auth in the house
AuthType Digest
AuthName "sample"
AuthDigestAlgorithm MD5
AuthDigestDomain http://sample.acme.com
AuthDigestNcCheck Off
AuthDigestNonceLifetime 0
AuthDigestQop auth
AuthDigestProvider file
AuthUserFile /etc/apache2/.htdigest
AuthGroupFile /dev/null
<LimitExcept GET HEAD OPTIONS POST>
require valid-user
</LimitExcept>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


Notice AuthUserFile /etc/apache2/.htdigest. That file was created using htdigest2 (or on most other systems, htdigest).

htdigest2 -c /etc/apache2/.htdigest sample acmeuser

The -c switch creates the file, "sample" correlates with the AuthName directive and acmeuser is the username of my demanding colleague. Also take note that the way I used LimitExcept allows all non-webDAV users to have anonymous access to the site, while any webDAV activity requires a username and password.

Next, I mapped a drive in Windows with the two methods I am familiar with. First, via the command line

W:\>net use * http://sample.acme.com
Enter the user name for 'sample.acme.com': acmeuser
Enter the password for sample.acme.com:
Drive X: is now connected to http://sample.acme.com.


And then via Windows Explorer (My Computer >> Map Network Drive [be sure to click "Connect Using Different Credentials"]). Both worked flawlessly. And of course, this is all better if you can do it over HTTPS, which I plan to setup when I have time. But for now, my servers are totally in style and ready for use by people who aren't fans of vi ;) .

Posted by: Chrissy   Filed under: Apache, Linux, Security, Windows Leave a comment
Comments (2) Trackbacks (0)
  1. Thank you for catering to my needs even though you do not agree with them sometimes! Excellent article.

  2. Chrissy -
    Will those directives work in a .htaccess file? I’d like to get my Win7 WebClient to talk to my hosting provider’s server. They are using cPanel which has “WebDisk” feature, so I know they support WebDAV somehow; however, they are using LiteSpeed, not Apache. Can I (at least theoretically) put these directives in my .htaccess file and get it to work?


Leave a comment


No trackbacks yet.