2025-06-19 - Setting up Breezy/Bazaar Loggerhead with nginx
Greetings travellers! Seems you have found my blog here and looking at how to set up a Loggerhead[Loggerhead] instance? then you have come to the right place!
"But... Why?" I hear you say. Well... Launchpad.net is dropping support for Bazaar repositories [LaunchpadBzr] , and I wanted to back up a few repos that I have worked on in the past, into a common place. This may seem a bit odd as I could just migrate to git and what not, but I have a love for Breezy and Bazaar.
Pre-requisite
The system
----------
OS: Debian 12
Webserver: nginx
To start off we need to install breezy and the build-deps for loggerhead.
# apt install brz
# apt build-dep loggerhead
Please note that all packages begining with bzr are just dummy packages.
With that out of the way we need to -- ironically -- fetch the git version of Loggerhead, as it's the most up to date, and the one in the Debian repos is a bit scuffed.
# brz branch https://github.com/breezy-team/loggerhead.git,branch=master
# cd loggerhead.git
Now we need to build and install Loggerhead, and please note where it is being installed. Or specify it with the appropriate flags to the install script. (I will just let it do it's job, and not worry about it). We need the locaton later!
# python setup.py build
# python setup.py install
##### Optionally install the manpage
# cp /usr/local/lib/python3.11/dist-packages/loggerhead-2.0.2.dev0-py3.11.egg/share/man/man1\
/usr/share/man/man1/
(Note that python setup.py clean does bugger-all.)
If you are on a local system you can now check if the thing works by running the following command, pointing to your Bazaar code repo, or an empy folder.
# loggerhead-serve --port=8833 /path/to/branches/
And then browsing to http://localhost:8833
init.d script, and confuguration
The service script is an old-style SystemV init script, and is the only way to configure the service. It needs to be copied and then edited. Do not worry, systemd has support for these types of init scripts.
# cp /usr/local/lib/python3.11/dist-packages/loggerhead-2.0.2.dev0-py3.11.egg/share/doc/loggerhead/loggerheadd\
/etc/init.d/
Now we need to edit the script. Open the script (/etc/init.d/loggerheadd) in your favourite editor.
And we need to set the port, code-repo path, and the the url-prefix.
Here follows my config:
LHUSER=loggerhead
if [ `whoami` = "$LHUSER" ]; then
SUDO=""
else
SUDO="sudo -H -u $LHUSER"
fi
# If loggerhead-serve is not in your path, you will need to specify the full path:
SERVE_BRANCHES_CMD=/usr/local/bin/loggerhead-serve
LOG_FOLDER=/var/log/loggerhead
LOG_FILE=$LOG_FOLDER/loggerheadd.log
URL_PREFIX=/bzr/
PORT=8833
#please specify the base directory to serve:
BZRROOT=/srv/bzr
# You can add additional options to loggerhead-serve here:
START_CMD="$SERVE_BRANCHES_CMD --prefix=$URL_PREFIX --log-folder=$LOG_FOLDER --port=$PORT $BZRROOT"
Reload systemd using systemctl daemon-reload. This needs to be whenever ever you
changes your configuration, as Loggerhead does not have a spacial configuration file.
Now we need to add the loggerhead user, and set up the code directory.
# adduser -r --no-create-home --group --system loggerhead
# mkdir -p /srv/bzr/
# brz init-repo /srv/bzr/
# chown -R loggerhead:loggerhead /srv/bzr/
# chmod -R a+rw /srv/bzr/ # AND/OR add users to the loggerhead group...
Now we can can start and enable the the daemon.
# systemctl enable loggerheadd
# systemctl start loggerheadd
Configuring nginx
Configuring nginx is quite easy! Here follows what I added to my default configuration, and it works. This is where you need to know where loggerhead is installed, as we need it for the static files.
server {
# .... stuff
location ^~ /bzr/ {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8833;
location ^~ /bzr/static/ {
alias '/usr/local/lib/python3.11/dist-packages/loggerhead-2.0.2.dev0-py3.11.egg/loggerhead/static/';
}
}
# .... more stuff
}
Now it's just a matter of reloading nginx, and you are all set on the web front.
# systemctl reload nginx
Now all you have to do is navigate to the specified URL, in my case gegoxaren.bato24.eu/bzr/.
Adding users and pushing code via ssh
Now we need to add users, and add them to the loggerhead group.
We can give the users a home and an actual login, but if you
want to restrict it so they can't login, you can pass the flags
we used above (exept the --system flag).
# adduser --group johndoe
# usermod -a -G loggerhead johndoe
Now the user can push code to your server using SSH from a different machine. (note that the servername and port are placeholders)
$ brz push --create-prefix brz+ssh://johndoe@myserver.eu:1234/srv/bzr/my-project/trunk
Bish-bosh-done. We are all done!
Bugs I've encountered.
Last updated 2025-06-10
Directories can't have the prefix bzr in my configuration. You'll get a 404.
I had a trailing / in my proxy_pass in the nginx configuration.
The "..." button does not work as expected when in the root of a branch. It pops you out in the wrong place. The "location bar" works, but not the "..." button.
<bound method Branch.revno of BzrBranch7(readonly+file://....)>
Gustav.
Footnotes
- [loggerhead]
- Loggerhead: https://launchpad.net/loggerhead, https://github.com/breezy-team/loggerhead
- [LaunchpadBzr]
- Announcement: https://discourse.ubuntu.com/t/phasing-out-bazaar-code-hosting/62189