In my last post I wrote about how to get libapache_mod_auth_pam to play nicely with Apache2. This post is about putting it all together, complete with WebSVN and a default web page so that one can write an introductory text to the users using the site.
Getting subversion up and running on Apache was explained in the last post. The problem with that, however, is that the Location directive means that all content on the site is directed to dav_svn. Hence, it is not possible to access an index.html page in the root, nor the /websvn folder. If you try, you will just get the message “Could not open the requested SVN filesystem”.
Of course, the simple solution to this would be to put the dav_svn module one folder down in the site structure (e.g. http://svn.example.com/repositories/<repository>) by changing the Location directive to <Location /repositories/>. But that is ugly.
I assume there are many ways to solve this but here is how I did it.
- First, create two sites – svn.example.com and websvn.example.com (or whatever you want to call them).
- Configure the site svn.example.com as explained in the previous post
- Configure the site websvn.example.com as you would any other static site, adding a index.html file in the root with whatever content you want to have there
- Now, before the Location directive in the svn.example.com site definition, add the following:
- Finally, you may also want to add SSL support for the svn.example.com site but I won’t go into that here
RewriteRule ^/$ index.html [R]
ProxyPass /websvn/ http://websvn.example.com/websvn/
ProxyPassReverse /websvn/ http://svn.example.com/websvn/
ProxyPass /index.html http://websvn.example.com/index.html
To make this work, a couple of Apache2 modules must be enabled, namely: proxy, proxy_http and rewrite.
What the above does is that it rewrites accesses to the root URL / to /index.html. Then, all requests to either /index.html or /websvn are proxied to the other site (which does not have dav_svn enabled so they work fine there).
With everything in place, you should be able to access http://svn.example.com for the index.html page, http://svn.example.com/websvn for the WebSVN interface to the repositories – and anything else for the real repositories.
A prettier solution would be if the Location directive for Apache supported negated regular expressions but I have come to the conclusion that it doesn’t – at least not the version I am using (2.2.8).