1
Serving Bazaar with FastCGI
2
===========================
1
Serving Bazaar with Apache
2
==========================
4
4
This document describes one way to set up a Bazaar HTTP smart server,
5
using Apache 2.0 and FastCGI or mod_python.
5
using Apache 2.0 and FastCGI or mod_python or mod_wsgi.
7
7
For more information on the smart server, and other ways to configure it
8
8
see the main `smart server documentation`_.
117
117
.. _mod_python: http://www.modpython.org/
123
First, configure mod_wsgi, e.g. enabling the mod with a2enmod wsgi.
124
We need to change it to handle all requests for URLs ending in `.bzr/smart`. It
127
WSGIScriptAliasMatch ^/code/.*/\.bzr/smart$ /srv/example.com/scripts/bzr.wsgi
129
#The three next lines allow regular GETs to work too
131
RewriteCond %{REQUEST_URI} !^/code/.*/\.bzr/smart$
132
RewriteRule ^/code/(.*/\.bzr/.*)$ /srv/example.com/www/code/$1 [L]
134
<Directory /srv/example.com/www/code>
135
WSGIApplicationGroup %{GLOBAL}
138
This instructs Apache to hand requests for any URL ending with `/.bzr/smart`
139
inside `/code` to a Bazaar smart server via WSGI, and any other URL inside
140
`/code` to be served directly by Apache.
142
Refer to the mod_wsgi_ documentation for further information.
144
.. _mod_wsgi: http://code.google.com/p/modwsgi/
120
146
Configuring Bazaar
121
147
------------------
171
197
return wsgi_server.run(request)
173
199
The `modpywsgi` module can be found at
174
http://dev.pocoo.org/projects/pocoo/browser/pocoo/wrappers/modpy.py. It is
200
http://ice.usq.edu.au/svn/ice/trunk/apps/ice-server/modpywsgi.py. It was
175
201
part of pocoo_. You sould make sure you place modpywsgi.py in the same
176
202
directory as bzr-smart.py (ie. /srv/example.com/scripts/).
178
204
.. _pocoo: http://dev.pocoo.org/projects/pocoo/
210
We've configured Apache to run the smart server at
211
`/srv/example.com/scripts/bzr.wsgi`. This is just a simple script we need
212
to write to configure a smart server, and glue it to the WSGI gateway.
213
Here's what it looks like::
215
from bzrlib.transport.http import wsgi
217
def application(environ, start_response):
219
root="/srv/example.com/www/code/",
222
enable_logging=False)
223
return app(environ, start_response)
183
Now you can use `bzr+http://` URLs, e.g.::
228
Now you can use `bzr+http://` URLs or just `http://` URLs, e.g.::
185
230
bzr log bzr+http://example.com/code/my-branch
216
260
.. _WSGI standard: http://www.python.org/dev/peps/pep-0333/
219
Pushing over ``bzr+http://``
220
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
263
Pushing over the http smart server
264
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
222
266
It is possible to allow pushing data over the http smart server. The
223
267
easiest way to do this, is to just supply ``readonly=False`` to the
224
268
``wsgi.make_app()`` call. But be careful, because the smart protocol does
225
269
not contain any Authentication. So if you enable write support, you will
226
270
want to restrict access to ``.bzr/smart`` URLs to restrict who can
227
actually write data on your system. At this time, it is not possible to
228
allow some people to have read-only access and others to have read-write
229
access to the same urls. Because at the HTTP layer (which is doing the
230
Authenticating), everything is just a POST request. However, it would
231
certainly be possible to have HTTPS require authentication and use a
232
writable server, and plain HTTP allow read-only access.
271
actually write data on your system, e.g. in apache it looks like::
276
AuthUserFile /srv/example.com/conf/auth.passwd
282
At this time, it is not possible to allow some people to have read-only
283
access and others to have read-write access to the same urls. Because at
284
the HTTP layer (which is doing the Authenticating), everything is just a
285
POST request. However, it would certainly be possible to have HTTPS
286
require authentication and use a writable server, and plain HTTP allow
289
If bzr gives an error like this when accessing your HTTPS site::
291
bzr: ERROR: Connection error: curl connection error (server certificate verification failed.
292
CAfile:/etc/ssl/certs/ca-certificates.crt CRLfile: none)
294
You can workaround it by using ``https+urllib`` rather than ``http`` in your
295
URL, or by uninstalling pycurl. See `bug 82086`_ for more details.
297
.. _bug 82086: https://bugs.launchpad.net/bzr/+bug/82086
236
300
vim: ft=rst tw=74 et