Loggerhead is a webfrontend for Bazaar (usually abbreviated as bzr) repositories. Bazaar is a so-called distributed version control system. So, if you have one or more bzr repositories you can use Loggerhead to look at the files, read the change logs and see the differences between revisions from within your web browser.
The main purpose of this post is to document the steps needed to configure Loggerhead and Apache to work together to publish your bzr repos on the web. The need for this post arose when I tried to get this setup to work and found that there isn’t a lot of documentation on how to get this done and most of it is out of date. The folowing steps were performed on a Linux server with Ubuntu 11.04 installed.
Basic Loggerhead configuration
First, let’s install Loggerhead:
$ aptitude install loggerhead
Although the package is called loggerhead, the actual binary that is run is called serve-branches. The package provides start and stop scripts for the service (
/etc/init.d/loggerhead), but to start successfully the file
/etc/serve-branches.conf needs to exist. Older documentation I found on the web refers to the file
/etc/loggerhead.conf, but that file has become obsolete.
serve-branches.conf file contains three lines:
served_branches=/home/bzr prefix= port=8080
Here, the line
served_branches points to the directory under which you store your bzr repositories. Each repo needs to be stored in its own directory. So in this example all the repos are in subdirectories of
You have to make sure that loggerhead can read the files in that directory. Loggerhead runs as the
loggerhead user but I made the directories readable and accessible by all users:
$ chmod -R a+rx /home/bzr/
If you now start Loggerhead:
$ service start loggerhead
you should be able to visit http://localhost:8080 in your browser and see your repositories.
NOTE for Ubuntu 12.04 and 12.10: There seems to be a bug in Loggerhead for these Ubuntu releases (see the link to the Launchpad bug report at the end of this post). In order to start the Loggerhead daemon correctly in these Ubuntu releases the file /etc/init.d/loggerhead must be edited. The line
start-stop-daemon -p $PIDFILE -S --startas /usr/bin/serve-branches --chuid loggerhead --make-pidfile --background --chdir $served_branches -- --prefix=$prefix --port=$port --host=$host --log-folder /var/log/loggerhead 2>/dev/null
must be changed to
start-stop-daemon -p $PIDFILE -S --startas /usr/bin/serve-branches --chuid loggerhead --make-pidfile --background -- file://$served_branches --prefix=$prefix --port=$port --log-folder /var/log/loggerhead 2>/dev/null
Once this is done run restart the Loggerhead service as stated above and it should work again (if you run Loggerhead behind an Apache webserver as detailed below, don’t forget to restart Apache also).
How to publish your branch to this shared repository?
Now that our repository browser is set up, how do we publish our branches to it so that there actually is something to browse through? Here is how you publish your branch to the server, assuming that you are in a directory that contains a branch and want to publish it as
$ bzr push --create-prefix sftp://firstname.lastname@example.org/home/bzr/myTests
As you probably suspected, the
--create-prefix option is only necessary the first time you push your branch. Note that we are using sftp here. Loggerhead itself doesn’t allow writes to the published repos. So, every user that want to push his/her changes to this repository needs to have sftp access to the
/home/bzr directory. I solved that problem by adding all people that need to be able to push changes to a Linux group called vcs (for Version Control Systems) and then set the primary group of
/home/bzr/ to vcs as well as giving group write permissions to this directory:
$ ls -ld /home/bzr/ drwxrwxr-x 4 root vcs 4096 2011-08-16 23:10 /home/bzr/
Adding Apache to the mix
In my case I already have a web server (Apache) running on port 80. Since I’d rather not open yet another port (8080 in this case) on my router, I wanted to use Apache to hand over the requests for bzr page to Loggerhead. For that I needed to install the following packages:
$ aptitude install python-pastedeploy
Next, I needed to change the contents of the
/etc/serve-branches.conf file to this:
served_branches=/home/bzr prefix=/bzr port=8080
The prefix indicates the location in the URL where Apache will serve the repos. In this case that will be http://server.yourdomain.com/bzr/.
And finally I needed to configure Apache. First, make sure that the
proxy-http modules are loaded:
$ a2enmod proxy proxy_http
Next, create a file
/etc/apache/conf.d/sites-available/loggerhead with the following contents:
# Configuration for browsing of Bazaar repos. Make sure loggerhead is running. <Location "/bzr/"> ProxyPass http://127.0.0.1:8080/ ProxyPassReverse http://127.0.0.1:8080/ </Location>
Note that Loggerhead and Apache run on the same host, that’s why I set the IP to 127.0.0.1.
Finally it’s time to enable the site and restart Apache:
$ a2ensite loggerhead $ service apache2 restart
Now it should be possible to browse your repos at http://server.yourdomain.com/bzr/. Note the final
/, it’s important.
Securing access with an LDAP connection
I have stored all my Unix user and group information in an LDAP server. To make sure that only people in the Unix group
vcs are allowed access to the loggerhead pages, change the Apache configuration file
loggerhead to the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Configuration for browsing of Bazaar repos. Make sure loggerhead is running. <Location "/bzr/"> ProxyPass http://127.0.0.1:8080/ ProxyPassReverse http://127.0.0.1:8080/ # LDAP authentication AuthType Basic AuthName "Karssen.org VCS users" AuthBasicProvider ldap AuthLDAPURL "ldap://ldap.yourdomain.com/ou=Users,dc=yourdomain,dc=com?uid" AuthLDAPGroupAttribute memberUid AuthLDAPGroupAttributeIsDN off Order Allow,Deny Allow From All Require ldap-group cn=vcs,ou=Groups,dc=yourdomain,dc=com </Location>
Lines 11 and 12 are needed because the
vcs group is not an LDAP group. I store my Unix (POSIX) groups in a separate OU in the LDAP tree (see line 15).
Don’t forget to restart Apache after making these changes.