~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to doc/http_smart_server.txt

  • Committer: Martin Pool
  • Date: 2007-04-04 06:17:31 UTC
  • mto: This revision was merged to the branch mainline in revision 2397.
  • Revision ID: mbp@sourcefrog.net-20070404061731-tt2xrzllqhbodn83
Contents of TODO file moved into bug tracker

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
===========================
1
2
Serving Bazaar with FastCGI
2
3
===========================
3
4
 
 
5
**This feature is EXPERIMENTAL and is NOT SECURE.  It will allow access to
 
6
arbitrary files on your server.**
 
7
 
4
8
This document describes one way to set up a Bazaar HTTP smart server,
5
9
using Apache 2.0 and FastCGI or mod_python.
6
10
 
7
 
For more information on the smart server, and other ways to configure it
8
 
see the main `smart server documentation`_.
9
 
 
10
 
.. _smart server documentation: #running-a-smart-server
11
 
 
12
11
Example
13
 
-------
 
12
=======
14
13
 
15
14
You have a webserver already publishing `/srv/example.com/www/code` as
16
15
`http://example.com/code/...` with plain HTTP.  It contains bzr branches and
46
45
 
47
46
    Alias /code /srv/example.com/www/code
48
47
    <Directory /srv/example.com/www/code>
49
 
        Options Indexes FollowSymLinks
 
48
        Options Indexes, FollowSymLinks
50
49
        RewriteEngine On
51
50
        RewriteBase /code
52
51
        RewriteRule ^(.*/|)\.bzr/smart$ /srv/example.com/scripts/bzr-smart.fcgi
102
101
This instructs Apache to hand requests for any URL ending with `/.bzr/smart`
103
102
inside `/code` to a Bazaar smart server via mod_python.
104
103
 
105
 
NOTE: If you don't have bzrlib in your PATH, you will be need to change the
106
 
following line::
107
 
 
108
 
            PythonPath "sys.path+['/srv/example.com/scripts']"
109
 
 
110
 
To::
111
 
 
112
 
            PythonPath "['/path/to/bzr']+sys.path+['/srv/example.com/scripts']"
113
 
 
114
 
 
115
104
Refer to the mod_python_ documentation for further information.
116
105
 
117
106
.. _mod_python: http://www.modpython.org/
132
121
    from bzrlib.transport.http import wsgi
133
122
 
134
123
    smart_server_app = wsgi.make_app(
135
 
        root='/srv/example.com/www/code',
 
124
        root='/srv/example.com/code',
136
125
        prefix='/code/',
137
126
        path_var='REQUEST_URI',
138
 
        readonly=True,
139
 
        load_plugins=True, 
140
 
        enable_logging=True)
 
127
        readonly=True)
141
128
 
142
129
    fcgi.WSGIServer(smart_server_app).run()
143
130
        
158
145
    from bzrlib.transport.http import wsgi
159
146
 
160
147
    smart_server_app = wsgi.make_app(
161
 
        root='/srv/example.com/www/code',
 
148
        root='/srv/example.com/code',
162
149
        prefix='/code/',
163
150
        path_var='REQUEST_URI',
164
 
        readonly=True,
165
 
        load_plugins=True, 
166
 
        enable_logging=True)
 
151
        readonly=True)
167
152
 
168
153
    def handler(request):
169
154
        """Handle a single request."""
170
155
        wsgi_server = modpywsgi.WSGIServer(smart_server_app)
171
156
        return wsgi_server.run(request)
172
157
        
173
 
The `modpywsgi` module can be found at
174
 
http://dev.pocoo.org/projects/pocoo/browser/pocoo/wrappers/modpy.py. It is
175
 
part of pocoo_. You sould make sure you place modpywsgi.py in the same
176
 
directory as bzr-smart.py (ie. /srv/example.com/scripts/).
 
158
The `modpywsgi` module can be found at http://trac.pocoo.org/wiki/ModPyWsgi.  It
 
159
is part of pocoo_.
177
160
 
178
 
.. _pocoo: http://dev.pocoo.org/projects/pocoo/
 
161
.. _pocoo: http://trac.pocoo.org/wiki/
179
162
 
180
163
Clients
181
164
-------
190
173
 
191
174
 
192
175
Advanced configuration
193
 
----------------------
 
176
======================
194
177
 
195
178
Because the Bazaar HTTP smart server is a WSGI application, it can be used with
196
179
any 3rd-party WSGI middleware or server that conforms the WSGI standard.  The
217
200
 
218
201
 
219
202
Pushing over ``bzr+http://``
220
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
203
----------------------------
221
204
 
222
205
It is possible to allow pushing data over the http smart server. The
223
206
easiest way to do this, is to just supply ``readonly=False`` to the