SVN over WebDAV (and proxy server)

I was setting up a project in LaunchPad and is trying to import the source from our SVN server. Since they can only do it via HTTP so I have to enable WebDAV support for my SVN server. But to make things complicate, the request have to get through a proxy server (err, 2 to be precise).

OK, so, what has to be done?

Firstly, you need to setup the mod_dav_svn on your SVN server.


Install apache server, I am using Gentoo Linux, so all I have to do is

emerge apache



And then, I need to enable apache in loading mod_dav_svn, so I modified /etc/conf.d/apache2

APACHE2_OPTS="-D DEFAULT_VHOST -D SSL -D SSL_DEFAULT_VHOST -D PHP5 -D DAV -D DAV_FS -D SVN"



After that, we have to define the context path, as well as the repository location. These information is stored in the config files for mod_dav_svn, mine is located under "modules.d "and named as "47_mod_dav_svn.conf". The file structure is something like the following, you might want to refer to the Red Book for details of each syntax.


<IfDefine SVN>
<IfModule !mod_dav_svn.c>
LoadModule dav_svn_module modules/mod_dav_svn.so
</IfModule>
<Location /src/xyz>
DAV svn
SVNPath /usr/local/repository/xyz
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /home/svn/svnconf/svnusers
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
SVNAutoVersioning On
SVNIndexXSLT /svnindex.xsl
</Location>
</IfDefine>



Restart apache and all should be done. Check by issuing the following command,

svn list http://localhost/src/xyz



Requesting the repository via a proxy server



My SVN server is sitting behind the firewall and all request has to be done from the web server in front of it. The web server is running apache and I can do that by using mod_proxy.

The source is served by one of the virtual host, and we need to modify the httpd.conf in configuring the mod_proxy.


<VirtualHost *>
ServerName www.mycode.com
....
<IfModule mod_proxy.c>
ProxyRequests Off
ProxyPass /src/xyz http://192.168.0.1/src/xyz
ProxyPassReverse /src/xyz http://192.168.0.1/src/xyz
CacheRoot "/path/to/write/proxy/file"
</IfModule>
</VirtualHost>



Note that I am only showing the excerpt. Restart apache and test by issuing the command

svn co http://www.mycode.com/src/xyz



If you can checkout properly, then, congratulation. You are all set :)

There's always some tricks



But I find that I am the unlucky one, and I have spot a couple of thing

1. In setting up the mod_dav_svn, the "Location" specified has to be the same as the "context path" you define in mod_proxy. For example,


ProxyPass /src/abc http://192.168.0.1/src/abc



It won't work if the request context path differs from the destination URL.

2. If your SVN server is installed behind a SQUID Proxy Server, you will need to make sure it supports all the DAV command that is required by SVN. Take a look at this .

Good luck!