I was looking for a way to easily share documents between machines, since WebDAV shares can be accessed by Windows, Linux or Mac machines out of the box, I choose WebDAV over SSL. I don’t use SSL for anything so WebDAV is served from DocumentRoot. I’ve been using it for a few days, so far it beats carrying USB sticks around.

Enable relevant Apache modules,

<code class=" apache">a2enmod ssl
a2enmod dav_fs
a2enmod <span class="keyword">dav</span>
</code>

Create SSL certificate,

<code class=" cpp"> mkdir /etc/apache2/ssl<br /> openssl req $@ -<span class="keyword">new</span> -x509 -days <span class="number">365</span> -nodes -out /etc/apache2/ssl/apache.pem \<br />     -keyout /etc/apache2/ssl/apache.pem<br /> chmod <span class="number">600</span> /etc/apache2/ssl/apache.pem<br /></code>

Create your WebDAV directory and create a password file,

<code class=" sql">mkdir /path/<span class="keyword">to</span>/webdav/<br />chown www-data /path/<span class="keyword">to</span>/webdav/<br />htpasswd -c /path/<span class="keyword">to</span>/passwd.dav <span class="keyword">user</span><br /></code>

Edit and add the following snippet to the configuration for the host you want to enable WebDAV,

<code class=" apache"> <span class="tag"><VirtualHost *:443></span><br />         <span class="keyword">ServerAdmin</span> <span class="keyword">user</span>@host.com<br />         <span class="keyword">DocumentRoot</span> /path/to/webdav<br /><br />         <span class="keyword">SSLEngine</span> <span class="literal">on</span><br />         <span class="keyword">SSLCertificateFile</span> /etc/apache2/ssl/apache.pem<br /><br />         <span class="tag"><Directory /path/to/webdav/></span><br />            <span class="keyword">DAV</span> <span class="literal">On</span><br />            <span class="keyword">AuthType</span> Basic<br />            <span class="keyword">AuthName</span> <span class="string">"webdav"</span><br />            <span class="keyword">AuthUserFile</span> /path/to/passwd.<span class="keyword">dav</span><br />            <span class="keyword">Require</span> valid-<span class="keyword">user</span><br />        <span class="tag"></Directory></span><br /><br />         <span class="keyword">ErrorLog</span>  /path/to/webdav/error.log<br />         <span class="keyword">CustomLog</span> /path/to/webdav/access.log combined<br /> <span class="tag"></VirtualHost></span><br /></code>

Reload Apache configuration,

<code>/etc/init.d/apache2 reload<br /><br />from <a target="_blank" href="http://nakkaya.com/2010/03/05/webdav-ssl-on-debian/">here</a><br /></code>
Advertisements