Subversion DIY write-through-proxy
Posted on Thursday, February 21st, 2008 | Filed under subversion
A lot of people seem to be eagerly awaiting the SVN 1.5 release so they can start implementing write-through-proxy. Not a lot of people seem to know that this is nothing more than a thin wrapper around existing Apache configuration capabilities. Here’s how you do it the old-fashioned way:
On your local mirror server(s):
<VirtualHost *:80>
ServerName mirror
<Location /repo>
DAV svn
SVNPath /path/to/mirrored/repo
RewriteEngine on
RewriteCond %{REQUEST_METHOD} !^GET$
RewriteCond %{REQUEST_METHOD} !^PROPFIND$
RewriteCond %{REQUEST_METHOD} !^OPTIONS$
RewriteCond %{REQUEST_METHOD} !^REPORT$
RewriteRule ^(.*)$ http://master%{REQUEST_URI} [P]
ProxyPassReverse http://master/repo
</Location>
<Location /repo-internal>
DAV svn
SVNPath /path/to/mirrored/repo
</Location>
</VirtualHost>
On your (remote) master server:
<VirtualHost *:80>
ServerName master
<Location /repo>
DAV svn
SVNPath /path/to/master/repo
</Location>
</VirtualHost>
Next, you need to initialize svnsync between the master and all its mirror repositories:
- Create the
pre-revprop-changehook on each mirror repository. For now, just have it alwaysexit 0. - For each mirror, run:
svnsync init http://mirror/repo-internal http://master/repo
To make the synchronization from master to mirror(s) work, you need to setup a number of hook scripts on both sides:
- Create the
post-commithook on the master repository, and for each mirror add a line like this:/usr/bin/svnsync sync --non-interactive http://mirror/repo-internal - Create the
post-revprop-changehook on the master repository, and for each mirror add a line like this:/usr/bin/svnsync copy-revprops http://mirror/repo-internal $REV
Next, if you’re planning on using this configuration in a production environment, you’ll want to add some security:
- Create an internal user (i.e. ’subversion’) to use for this configuration. You’ll need this account on both master and mirror(s).
- Edit the
pre-revprop-changehook on each mirror repository to restrict revision property changes. Make sure your internal user is allowed here. E.g.:
if [ "$USER" = "[internal user]" ]; then exit 0; fi
exit 1
- Add
--username [internal user] --password [password of internal user]to the svnsync commands in the post-commit hook on the master repository.
Comments
3 Responses to “Subversion DIY write-through-proxy”
Leave a Reply
With SVN >1.5 just use the provided Apache directives for write-through proxy instead:
http://subversion.tigris.org/svn_1.5_releasenotes.html#webdav-proxy
SVN move and rename not working for files and folders in slave repository
Apache : 2.2.11
Subversion server : 6.2
While rename a file it gives the following error
svn: Commit failed (details follow):
svn: Server sent unexpected return value (405 Method Not Allowed) in response to COPY request for ‘/slave/qa1/helloiamthe_masteronqa1/!svn/bc/17/branches’
Similarly while moving the folder gives the following error
svn: Server sent unexpected return value (405 Method Not Allowed)
Please let me know if anyone has any clues on this.
Thanks
Nick
[...] about implementing it in this articles: Subversion transparent proxy with svnsync + webdav proxy subversion diy write through proxy Subversion on-the-fly [...]