Refactoring RubyForge svn+http directives

18 Aug 2009

I was inspired by the guys over at beanstalkapp to look at the way the RubyForge virtual hosts handle svn+http. Here's the old way:

<Location /svn>
  DAV svn
  SVNPathAuthz off
  SVNPath /var/svn/support
  <LimitExcept GET PROPFIND OPTIONS REPORT>
    deny from all
  </LimitExcept>
</Location>

Pretty straightforward, but since all the virtual hosts have pretty much the same directives, here's the new way:

<Location /svn>
  SVNPath /var/svn/support
</Location>

Much more concise! All of the duplicated stuff got moved up into a global Location directive and only the host-specific stuff remains. This makes each of the virtual hosts that include svn+http support about a third smaller, which means faster Apache restarts and all around goodness.

The downside is that now all virtual hosts include a /svn URL - it's there even if that project only uses git or cvs. Kind of clonky. It'd also be nice to get rid of SVNPath, but unfortunately I think the way we have /svn hanging off the root of the virtual host prevents that.

One day I should look at mod_vhost_alias. 99% of the RubyForge virtual hosts are exactly the same less the project name. Seems like it should be possible to refactor away almost all of them.