/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6622.1.23 by Jelmer Vernooij
More renames in English docs.
1
Serving Breezy with Apache
5053.3.1 by Agustin Henze - TiN
Add example for mod_wsgi and other little corrections
2
==========================
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
3
6622.1.23 by Jelmer Vernooij
More renames in English docs.
4
This document describes one way to set up a Breezy HTTP smart server,
5053.3.1 by Agustin Henze - TiN
Add example for mod_wsgi and other little corrections
5
using Apache 2.0 and FastCGI or mod_python or mod_wsgi.
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
6
2601.1.2 by James Westby
Add a reference to the main smart server documentation.
7
For more information on the smart server, and other ways to configure it
5452.3.1 by David Muir
fixed link to point to smart server documentation
8
see the main `smart server documentation <server.html>`_.
2601.1.2 by James Westby
Add a reference to the main smart server documentation.
9
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
10
Example
2977.1.1 by Ian Clatworthy
First cut at new look User Guide including chapters 1 and 2
11
-------
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
12
13
You have a webserver already publishing `/srv/example.com/www/code` as
6622.1.23 by Jelmer Vernooij
More renames in English docs.
14
`http://example.com/code/...` with plain HTTP.  It contains branches and
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
15
directories like `/srv/example.com/www/code/branch-one` and
2018.4.2 by Andrew Bennetts
Add security warning to http_smart_server.txt.
16
`/srv/example.com/www/code/my-repo/branch-two`.  You want to provide read-only
17
smart server access to these directories in addition to the existing HTTP
18
access.
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
19
20
Configuring Apache 2.0
21
----------------------
22
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
23
FastCGI
24
~~~~~~~
25
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
26
First, configure mod_fastcgi, e.g. by adding lines like these to your
27
httpd.conf::
28
29
    LoadModule fastcgi_module /usr/lib/apache2/modules/mod_fastcgi.so
30
    FastCgiIpcDir /var/lib/apache2/fastcgi
4853.1.1 by Patrick Regan
Removed trailing whitespace from files in doc directory
31
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
32
In our example, we're already serving `/srv/example.com/www/code` at
33
`http://example.com/code`, so our existing Apache configuration would look
34
like::
35
36
    Alias /code /srv/example.com/www/code
37
    <Directory /srv/example.com/www/code>
38
        Options Indexes
39
        # ...
40
    </Directory>
41
6622.1.24 by Jelmer Vernooij
More doc renames.
42
We need to change it to handle all requests for URLs ending in `.brz/smart`.  It
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
43
will look like::
44
45
    Alias /code /srv/example.com/www/code
46
    <Directory /srv/example.com/www/code>
2706.1.1 by Martin Albisetti
updated smart server documentation
47
        Options Indexes FollowSymLinks
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
48
        RewriteEngine On
49
        RewriteBase /code
6622.1.23 by Jelmer Vernooij
More renames in English docs.
50
        RewriteRule ^(.*/)?\.bzr/smart$ /srv/example.com/scripts/brz-smart.fcgi
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
51
    </Directory>
4853.1.1 by Patrick Regan
Removed trailing whitespace from files in doc directory
52
6622.1.23 by Jelmer Vernooij
More renames in English docs.
53
    # brz-smart.fcgi isn't under the DocumentRoot, so Alias it into the URL
2018.4.5 by Andrew Bennetts
Improvement thanks to John's review.
54
    # namespace so it can be executed.
6622.1.23 by Jelmer Vernooij
More renames in English docs.
55
    Alias /srv/example.com/scripts/brz-smart.fcgi /srv/example.com/scripts/brz-smart.fcgi
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
56
    <Directory /srv/example.com/scripts>
57
        Options ExecCGI
6622.1.23 by Jelmer Vernooij
More renames in English docs.
58
        <Files brz-smart.fcgi>
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
59
            SetHandler fastcgi-script
60
        </Files>
61
    </Directory>
4853.1.1 by Patrick Regan
Removed trailing whitespace from files in doc directory
62
6622.1.24 by Jelmer Vernooij
More doc renames.
63
This instructs Apache to hand requests for any URL ending with `/.brz/smart`
6622.1.23 by Jelmer Vernooij
More renames in English docs.
64
inside `/code` to a Breezy smart server via FastCGI.
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
65
66
Refer to the mod_rewrite_ and mod_fastcgi_ documentation for further
67
information.
68
69
.. _mod_rewrite: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
70
.. _mod_fastcgi: http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html
71
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
72
mod_python
73
~~~~~~~~~~
74
75
First, configure mod_python, e.g. by adding lines like these to your
76
httpd.conf::
77
78
    LoadModule python_module /usr/lib/apache2/modules/mod_python.so
79
80
Define the rewrite rules with mod_rewrite the same way as for FastCGI, except
81
change::
82
6622.1.23 by Jelmer Vernooij
More renames in English docs.
83
    RewriteRule ^(.*/)?\.bzr/smart$ /srv/example.com/scripts/brz-smart.fcgi
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
84
85
to::
86
6622.1.23 by Jelmer Vernooij
More renames in English docs.
87
    RewriteRule ^(.*/)?\.bzr/smart$ /srv/example.com/scripts/brz-smart.py
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
88
89
Like with mod_fastcgi, we also define how our script is to be handled::
90
6622.1.23 by Jelmer Vernooij
More renames in English docs.
91
    Alias /srv/example.com/scripts/brz-smart.py /srv/example.com/scripts/brz-smart.py
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
92
    <Directory /srv/example.com/scripts>
6622.1.23 by Jelmer Vernooij
More renames in English docs.
93
        <Files brz-smart.py>
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
94
            PythonPath "sys.path+['/srv/example.com/scripts']"
95
            AddHandler python-program .py
6622.1.23 by Jelmer Vernooij
More renames in English docs.
96
            PythonHandler brz-smart::handler
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
97
        </Files>
98
    </Directory>
99
6622.1.24 by Jelmer Vernooij
More doc renames.
100
This instructs Apache to hand requests for any URL ending with `/.brz/smart`
6622.1.23 by Jelmer Vernooij
More renames in English docs.
101
inside `/code` to a Breezy smart server via mod_python.
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
102
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
103
NOTE: If you don't have breezy in your PATH, you will be need to change the
2706.1.3 by Aaron Bentley
Style tweakage and NEWS
104
following line::
2706.1.1 by Martin Albisetti
updated smart server documentation
105
106
            PythonPath "sys.path+['/srv/example.com/scripts']"
107
2706.1.3 by Aaron Bentley
Style tweakage and NEWS
108
To::
2706.1.1 by Martin Albisetti
updated smart server documentation
109
6622.1.23 by Jelmer Vernooij
More renames in English docs.
110
            PythonPath "['/path/to/brz']+sys.path+['/srv/example.com/scripts']"
2706.1.1 by Martin Albisetti
updated smart server documentation
111
112
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
113
Refer to the mod_python_ documentation for further information.
114
115
.. _mod_python: http://www.modpython.org/
116
117
5053.3.1 by Agustin Henze - TiN
Add example for mod_wsgi and other little corrections
118
mod_wsgi
119
~~~~~~~~
120
121
First, configure mod_wsgi, e.g. enabling the mod with a2enmod wsgi.
6622.1.24 by Jelmer Vernooij
More doc renames.
122
We need to change it to handle all requests for URLs ending in `.brz/smart`.  It
5053.3.1 by Agustin Henze - TiN
Add example for mod_wsgi and other little corrections
123
will look like::
124
6622.1.23 by Jelmer Vernooij
More renames in English docs.
125
    WSGIScriptAliasMatch ^/code/.*/\.bzr/smart$ /srv/example.com/scripts/brz.wsgi
5053.3.1 by Agustin Henze - TiN
Add example for mod_wsgi and other little corrections
126
5053.3.2 by Agustin Henze - TiN
Small fixes Andrew Bennetts
127
    #The three next lines allow regular GETs to work too
5053.3.1 by Agustin Henze - TiN
Add example for mod_wsgi and other little corrections
128
    RewriteEngine On
5053.3.2 by Agustin Henze - TiN
Small fixes Andrew Bennetts
129
    RewriteCond %{REQUEST_URI} !^/code/.*/\.bzr/smart$
130
    RewriteRule ^/code/(.*/\.bzr/.*)$ /srv/example.com/www/code/$1 [L]
5053.3.1 by Agustin Henze - TiN
Add example for mod_wsgi and other little corrections
131
132
    <Directory /srv/example.com/www/code>
133
        WSGIApplicationGroup %{GLOBAL}
134
    </Directory>
135
6622.1.24 by Jelmer Vernooij
More doc renames.
136
This instructs Apache to hand requests for any URL ending with `/.brz/smart`
6622.1.23 by Jelmer Vernooij
More renames in English docs.
137
inside `/code` to a Breezy smart server via WSGI, and any other URL inside
5053.3.3 by Agustin Henze - TiN
Added suggestions for Andrew Bennetts and revised the entire document
138
`/code` to be served directly by Apache.
5053.3.1 by Agustin Henze - TiN
Add example for mod_wsgi and other little corrections
139
140
Refer to the mod_wsgi_ documentation for further information.
141
142
.. _mod_wsgi: http://code.google.com/p/modwsgi/
143
6622.1.23 by Jelmer Vernooij
More renames in English docs.
144
Configuring Breezy
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
145
------------------
146
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
147
FastCGI
148
~~~~~~~
149
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
150
We've configured Apache to run the smart server at
6622.1.23 by Jelmer Vernooij
More renames in English docs.
151
`/srv/example.com/scripts/brz-smart.fcgi`.  This is just a simple script we need
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
152
to write to configure a smart server, and glue it to the FastCGI gateway.
153
Here's what it looks like::
154
155
    import fcgi
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
156
    from breezy.transport.http import wsgi
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
157
158
    smart_server_app = wsgi.make_app(
3702.3.1 by Jonathan Lange
Update the location of modpywsgi and the location of pocoo.
159
        root='/srv/example.com/www/code',
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
160
        prefix='/code/',
2190.1.4 by John Arbash Meinel
Add ability to enable writeable bzr+http access.
161
        path_var='REQUEST_URI',
3708.1.3 by Marius Kruger
note extra options to wsgi.make_app in docs
162
        readonly=True,
4853.1.1 by Patrick Regan
Removed trailing whitespace from files in doc directory
163
        load_plugins=True,
3708.1.3 by Marius Kruger
note extra options to wsgi.make_app in docs
164
        enable_logging=True)
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
165
166
    fcgi.WSGIServer(smart_server_app).run()
4853.1.1 by Patrick Regan
Removed trailing whitespace from files in doc directory
167
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
168
The `fcgi` module can be found at http://svn.saddi.com/py-lib/trunk/fcgi.py.  It
169
is part of flup_.
170
171
.. _flup: http://www.saddi.com/software/flup/
172
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
173
mod_python
174
~~~~~~~~~~
175
176
We've configured Apache to run the smart server at
6622.1.23 by Jelmer Vernooij
More renames in English docs.
177
`/srv/example.com/scripts/brz-smart.py`.  This is just a simple script we need
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
178
to write to configure a smart server, and glue it to the mod_python gateway.
179
Here's what it looks like::
180
181
    import modpywsgi
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
182
    from breezy.transport.http import wsgi
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
183
184
    smart_server_app = wsgi.make_app(
3702.3.1 by Jonathan Lange
Update the location of modpywsgi and the location of pocoo.
185
        root='/srv/example.com/www/code',
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
186
        prefix='/code/',
2190.1.4 by John Arbash Meinel
Add ability to enable writeable bzr+http access.
187
        path_var='REQUEST_URI',
3708.1.3 by Marius Kruger
note extra options to wsgi.make_app in docs
188
        readonly=True,
4853.1.1 by Patrick Regan
Removed trailing whitespace from files in doc directory
189
        load_plugins=True,
3708.1.3 by Marius Kruger
note extra options to wsgi.make_app in docs
190
        enable_logging=True)
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
191
2190.1.1 by John Arbash Meinel
Update the documentation so the smart server actually works with mod python.
192
    def handler(request):
193
        """Handle a single request."""
194
        wsgi_server = modpywsgi.WSGIServer(smart_server_app)
195
        return wsgi_server.run(request)
4853.1.1 by Patrick Regan
Removed trailing whitespace from files in doc directory
196
3702.3.1 by Jonathan Lange
Update the location of modpywsgi and the location of pocoo.
197
The `modpywsgi` module can be found at
5053.3.1 by Agustin Henze - TiN
Add example for mod_wsgi and other little corrections
198
http://ice.usq.edu.au/svn/ice/trunk/apps/ice-server/modpywsgi.py. It was
3702.3.1 by Jonathan Lange
Update the location of modpywsgi and the location of pocoo.
199
part of pocoo_. You sould make sure you place modpywsgi.py in the same
6622.1.23 by Jelmer Vernooij
More renames in English docs.
200
directory as brz-smart.py (ie. /srv/example.com/scripts/).
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
201
3702.3.1 by Jonathan Lange
Update the location of modpywsgi and the location of pocoo.
202
.. _pocoo: http://dev.pocoo.org/projects/pocoo/
2180.2.1 by Andrew Bennetts
Describe smart server configuration with mod_python.
203
5053.3.1 by Agustin Henze - TiN
Add example for mod_wsgi and other little corrections
204
205
mod_wsgi
206
~~~~~~~~
207
208
We've configured Apache to run the smart server at
6622.1.23 by Jelmer Vernooij
More renames in English docs.
209
`/srv/example.com/scripts/brz.wsgi`.  This is just a simple script we need
5053.3.1 by Agustin Henze - TiN
Add example for mod_wsgi and other little corrections
210
to write to configure a smart server, and glue it to the WSGI gateway.
211
Here's what it looks like::
212
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
213
    from breezy.transport.http import wsgi
5053.3.1 by Agustin Henze - TiN
Add example for mod_wsgi and other little corrections
214
215
    def application(environ, start_response):
216
        app = wsgi.make_app(
217
            root="/srv/example.com/www/code/",
218
            prefix="/code",
5053.3.3 by Agustin Henze - TiN
Added suggestions for Andrew Bennetts and revised the entire document
219
            readonly=True,
5053.3.1 by Agustin Henze - TiN
Add example for mod_wsgi and other little corrections
220
            enable_logging=False)
221
        return app(environ, start_response)
222
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
223
Clients
224
-------
225
6622.1.23 by Jelmer Vernooij
More renames in English docs.
226
Now you can use `brz+http://` URLs or just `http://` URLs, e.g.::
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
227
6622.1.23 by Jelmer Vernooij
More renames in English docs.
228
    brz log brz+http://example.com/code/my-branch
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
229
230
Plain HTTP access should continue to work::
231
6622.1.23 by Jelmer Vernooij
More renames in English docs.
232
    brz log http://example.com/code/my-branch
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
233
234
Advanced configuration
2977.1.1 by Ian Clatworthy
First cut at new look User Guide including chapters 1 and 2
235
----------------------
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
236
6622.1.23 by Jelmer Vernooij
More renames in English docs.
237
Because the Breezy HTTP smart server is a WSGI application, it can be used with
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
238
any 3rd-party WSGI middleware or server that conforms the WSGI standard.  The
239
only requirements are:
240
241
  * to construct a `SmartWSGIApp`, you need to specify a **root transport** that it
242
    will serve.
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
243
  * each request's `environ` dict must have a **'breezy.relpath'** variable set.
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
244
245
The `make_app` helper used in the example constructs a `SmartWSGIApp` with a
246
transport based on the `root` path given to it, and calculates the
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
247
'breezy.relpath` for each request based on the `prefix` and `path_var`
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
248
arguments.  In the example above, it will take the 'REQUEST_URI' (which is set
6622.1.24 by Jelmer Vernooij
More doc renames.
249
by Apache), strip the '/code/' prefix and the '/.brz/smart' suffix, and set that
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
250
as the 'breezy.relpath', so that a request for '/code/foo/bar/.brz/smart' will
251
result in a 'breezy.relpath' of 'foo/brz'.
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
252
253
It's possible to configure a smart server for a non-local transport, or that
254
does arbitrary path translations, etc, by constructing a `SmartWSGIApp`
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
255
directly.  Refer to the docstrings of `breezy.transport.http.wsgi` and the `WSGI
2018.4.1 by Andrew Bennetts
Add WSGI smart server.
256
standard`_ for further information.
257
258
.. _WSGI standard: http://www.python.org/dev/peps/pep-0333/
259
2190.1.4 by John Arbash Meinel
Add ability to enable writeable bzr+http access.
260
5538.2.1 by Zearin
Fixed capitalization of XML and HTTP. Fixed by hand and only where appropriate (e.g., left http://some/url lowercase, but capitalized "When making an HTTP request…").
261
Pushing over the HTTP smart server
5053.3.3 by Agustin Henze - TiN
Added suggestions for Andrew Bennetts and revised the entire document
262
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2190.1.4 by John Arbash Meinel
Add ability to enable writeable bzr+http access.
263
5538.2.1 by Zearin
Fixed capitalization of XML and HTTP. Fixed by hand and only where appropriate (e.g., left http://some/url lowercase, but capitalized "When making an HTTP request…").
264
It is possible to allow pushing data over the HTTP smart server. The
2190.1.4 by John Arbash Meinel
Add ability to enable writeable bzr+http access.
265
easiest way to do this, is to just supply ``readonly=False`` to the
266
``wsgi.make_app()`` call. But be careful, because the smart protocol does
267
not contain any Authentication. So if you enable write support, you will
6622.1.24 by Jelmer Vernooij
More doc renames.
268
want to restrict access to ``.brz/smart`` URLs to restrict who can
5053.3.3 by Agustin Henze - TiN
Added suggestions for Andrew Bennetts and revised the entire document
269
actually write data on your system, e.g. in apache it looks like::
270
271
    <Location /code>
272
        AuthType Basic
273
        AuthName "example"
274
        AuthUserFile /srv/example.com/conf/auth.passwd
275
        <LimitExcept GET>
276
            Require valid-user
277
        </LimitExcept>
278
    </Location>
279
280
At this time, it is not possible to allow some people to have read-only
5538.2.3 by Zearin
Continued capitalization fixes. (URL, URLs)
281
access and others to have read-write access to the same URLs. Because at
5053.3.3 by Agustin Henze - TiN
Added suggestions for Andrew Bennetts and revised the entire document
282
the HTTP layer (which is doing the Authenticating), everything is just a
283
POST request.  However, it would certainly be possible to have HTTPS
284
require authentication and use a writable server, and plain HTTP allow
285
read-only access.
286
6622.1.23 by Jelmer Vernooij
More renames in English docs.
287
If brz gives an error like this when accessing your HTTPS site::
5053.3.3 by Agustin Henze - TiN
Added suggestions for Andrew Bennetts and revised the entire document
288
6622.1.23 by Jelmer Vernooij
More renames in English docs.
289
  brz: ERROR: Connection error: curl connection error (server certificate verification failed.
5053.3.3 by Agustin Henze - TiN
Added suggestions for Andrew Bennetts and revised the entire document
290
  CAfile:/etc/ssl/certs/ca-certificates.crt CRLfile: none)
291
292
You can workaround it by using ``https+urllib`` rather than ``http`` in your
293
URL, or by uninstalling pycurl.  See `bug 82086`_ for more details.
5053.3.2 by Agustin Henze - TiN
Small fixes Andrew Bennetts
294
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
295
.. _bug 82086: https://bugs.launchpad.net/bzr/+bug/82086
2190.1.4 by John Arbash Meinel
Add ability to enable writeable bzr+http access.
296
4853.1.1 by Patrick Regan
Removed trailing whitespace from files in doc directory
297
..
2190.1.1 by John Arbash Meinel
Update the documentation so the smart server actually works with mod python.
298
   vim: ft=rst tw=74 et