/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to doc/http_smart_server.txt

Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
arbitrary files on your server.**
7
7
 
8
8
This document describes one way to setup a Bazaar HTTP smart server, using
9
 
Apache 2.0 and FastCGI.
 
9
Apache 2.0 and FastCGI or mod_python.
10
10
 
11
11
Example
12
12
=======
21
21
Configuring Apache 2.0
22
22
----------------------
23
23
 
 
24
FastCGI
 
25
~~~~~~~
 
26
 
24
27
First, configure mod_fastcgi, e.g. by adding lines like these to your
25
28
httpd.conf::
26
29
 
45
48
        Options Indexes, FollowSymLinks
46
49
        RewriteEngine On
47
50
        RewriteBase /code
48
 
        RewriteRule ^(.*)/\.bzr/smart$ /srv/example.com/scripts/bzr-smart.fcgi
 
51
        RewriteRule ^(.*/|)\.bzr/smart$ /srv/example.com/scripts/bzr-smart.fcgi
49
52
    </Directory>
50
53
    
51
54
    # bzr-smart.fcgi isn't under the DocumentRoot, so Alias it into the URL
67
70
.. _mod_rewrite: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
68
71
.. _mod_fastcgi: http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html
69
72
 
 
73
mod_python
 
74
~~~~~~~~~~
 
75
 
 
76
First, configure mod_python, e.g. by adding lines like these to your
 
77
httpd.conf::
 
78
 
 
79
    LoadModule python_module /usr/lib/apache2/modules/mod_python.so
 
80
 
 
81
Define the rewrite rules with mod_rewrite the same way as for FastCGI, except
 
82
change::
 
83
 
 
84
    RewriteRule ^(.*/|)\.bzr/smart$ /srv/example.com/scripts/bzr-smart.fcgi
 
85
 
 
86
to::
 
87
 
 
88
    RewriteRule ^(.*/|)\.bzr/smart$ /srv/example.com/scripts/bzr-smart.py
 
89
 
 
90
Like with mod_fastcgi, we also define how our script is to be handled::
 
91
 
 
92
    Alias /srv/example.com/scripts/bzr-smart.py /srv/example.com/scripts/bzr-smart.py
 
93
    <Directory /srv/example.com/scripts>
 
94
        <Files bzr-smart.py>
 
95
            PythonPath "sys.path+['/srv/example.com/scripts']"
 
96
            AddHandler python-program .py
 
97
            PythonHandler bzr-smart::handler
 
98
        </Files>
 
99
    </Directory>
 
100
 
 
101
This instructs Apache to hand requests for any URL ending with `/.bzr/smart`
 
102
inside `/code` to a Bazaar smart server via mod_python.
 
103
 
 
104
Refer to the mod_python_ documentation for further information.
 
105
 
 
106
.. _mod_python: http://www.modpython.org/
 
107
 
 
108
 
70
109
Configuring Bazaar
71
110
------------------
72
111
 
 
112
FastCGI
 
113
~~~~~~~
 
114
 
73
115
We've configured Apache to run the smart server at
74
116
`/srv/example.com/scripts/bzr-smart.fcgi`.  This is just a simple script we need
75
117
to write to configure a smart server, and glue it to the FastCGI gateway.
81
123
    smart_server_app = wsgi.make_app(
82
124
        root='/srv/example.com/code',
83
125
        prefix='/code/',
84
 
        path_var='REQUEST_URI')
 
126
        path_var='REQUEST_URI',
 
127
        readonly=True)
85
128
 
86
129
    fcgi.WSGIServer(smart_server_app).run()
87
130
        
90
133
 
91
134
.. _flup: http://www.saddi.com/software/flup/
92
135
 
 
136
mod_python
 
137
~~~~~~~~~~
 
138
 
 
139
We've configured Apache to run the smart server at
 
140
`/srv/example.com/scripts/bzr-smart.py`.  This is just a simple script we need
 
141
to write to configure a smart server, and glue it to the mod_python gateway.
 
142
Here's what it looks like::
 
143
 
 
144
    import modpywsgi
 
145
    from bzrlib.transport.http import wsgi
 
146
 
 
147
    smart_server_app = wsgi.make_app(
 
148
        root='/srv/example.com/code',
 
149
        prefix='/code/',
 
150
        path_var='REQUEST_URI',
 
151
        readonly=True)
 
152
 
 
153
    def handler(request):
 
154
        """Handle a single request."""
 
155
        wsgi_server = modpywsgi.WSGIServer(smart_server_app)
 
156
        return wsgi_server.run(request)
 
157
        
 
158
The `modpywsgi` module can be found at http://trac.pocoo.org/wiki/ModPyWsgi.  It
 
159
is part of pocoo_.
 
160
 
 
161
.. _pocoo: http://trac.pocoo.org/wiki/
 
162
 
93
163
Clients
94
164
-------
95
165
 
128
198
 
129
199
.. _WSGI standard: http://www.python.org/dev/peps/pep-0333/
130
200
 
 
201
 
 
202
Pushing over ``bzr+http://``
 
203
----------------------------
 
204
 
 
205
It is possible to allow pushing data over the http smart server. The
 
206
easiest way to do this, is to just supply ``readonly=False`` to the
 
207
``wsgi.make_app()`` call. But be careful, because the smart protocol does
 
208
not contain any Authentication. So if you enable write support, you will
 
209
want to restrict access to ``.bzr/smart`` URLs to restrict who can
 
210
actually write data on your system.  At this time, it is not possible to
 
211
allow some people to have read-only access and others to have read-write
 
212
access to the same urls. Because at the HTTP layer (which is doing the
 
213
Authenticating), everything is just a POST request.  However, it would
 
214
certainly be possible to have HTTPS require authentication and use a
 
215
writable server, and plain HTTP allow read-only access.
 
216
 
 
217
 
 
218
.. 
 
219
   vim: ft=rst tw=74 et