~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to doc/http_smart_server.txt

  • Committer: Robert Collins
  • Date: 2007-08-06 23:49:18 UTC
  • mto: (2592.3.81 repository)
  • mto: This revision was merged to the branch mainline in revision 2933.
  • Revision ID: robertc@robertcollins.net-20070806234918-xc9w5f86tgjphf9u
Prevent the duplicate additions of names to FileNames collections.

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
11
For more information on the smart server, and other ways to configure it
8
12
see the main `smart server documentation`_.
9
13
 
10
 
.. _smart server documentation: #running-a-smart-server
 
14
.. _smart server documentation: server.htm
11
15
 
12
16
Example
13
 
-------
 
17
=======
14
18
 
15
19
You have a webserver already publishing `/srv/example.com/www/code` as
16
20
`http://example.com/code/...` with plain HTTP.  It contains bzr branches and
30
34
 
31
35
    LoadModule fastcgi_module /usr/lib/apache2/modules/mod_fastcgi.so
32
36
    FastCgiIpcDir /var/lib/apache2/fastcgi
33
 
 
 
37
    
34
38
In our example, we're already serving `/srv/example.com/www/code` at
35
39
`http://example.com/code`, so our existing Apache configuration would look
36
40
like::
46
50
 
47
51
    Alias /code /srv/example.com/www/code
48
52
    <Directory /srv/example.com/www/code>
49
 
        Options Indexes FollowSymLinks
 
53
        Options Indexes, FollowSymLinks
50
54
        RewriteEngine On
51
55
        RewriteBase /code
52
56
        RewriteRule ^(.*/|)\.bzr/smart$ /srv/example.com/scripts/bzr-smart.fcgi
53
57
    </Directory>
54
 
 
 
58
    
55
59
    # bzr-smart.fcgi isn't under the DocumentRoot, so Alias it into the URL
56
60
    # namespace so it can be executed.
57
61
    Alias /srv/example.com/scripts/bzr-smart.fcgi /srv/example.com/scripts/bzr-smart.fcgi
61
65
            SetHandler fastcgi-script
62
66
        </Files>
63
67
    </Directory>
64
 
 
 
68
    
65
69
This instructs Apache to hand requests for any URL ending with `/.bzr/smart`
66
70
inside `/code` to a Bazaar smart server via FastCGI.
67
71
 
102
106
This instructs Apache to hand requests for any URL ending with `/.bzr/smart`
103
107
inside `/code` to a Bazaar smart server via mod_python.
104
108
 
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
109
Refer to the mod_python_ documentation for further information.
116
110
 
117
111
.. _mod_python: http://www.modpython.org/
132
126
    from bzrlib.transport.http import wsgi
133
127
 
134
128
    smart_server_app = wsgi.make_app(
135
 
        root='/srv/example.com/www/code',
 
129
        root='/srv/example.com/code',
136
130
        prefix='/code/',
137
131
        path_var='REQUEST_URI',
138
 
        readonly=True,
139
 
        load_plugins=True,
140
 
        enable_logging=True)
 
132
        readonly=True)
141
133
 
142
134
    fcgi.WSGIServer(smart_server_app).run()
143
 
 
 
135
        
144
136
The `fcgi` module can be found at http://svn.saddi.com/py-lib/trunk/fcgi.py.  It
145
137
is part of flup_.
146
138
 
158
150
    from bzrlib.transport.http import wsgi
159
151
 
160
152
    smart_server_app = wsgi.make_app(
161
 
        root='/srv/example.com/www/code',
 
153
        root='/srv/example.com/code',
162
154
        prefix='/code/',
163
155
        path_var='REQUEST_URI',
164
 
        readonly=True,
165
 
        load_plugins=True,
166
 
        enable_logging=True)
 
156
        readonly=True)
167
157
 
168
158
    def handler(request):
169
159
        """Handle a single request."""
170
160
        wsgi_server = modpywsgi.WSGIServer(smart_server_app)
171
161
        return wsgi_server.run(request)
172
 
 
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/).
177
 
 
178
 
.. _pocoo: http://dev.pocoo.org/projects/pocoo/
 
162
        
 
163
The `modpywsgi` module can be found at http://trac.pocoo.org/wiki/ModPyWsgi.  It
 
164
is part of pocoo_.
 
165
 
 
166
.. _pocoo: http://trac.pocoo.org/wiki/
179
167
 
180
168
Clients
181
169
-------
190
178
 
191
179
 
192
180
Advanced configuration
193
 
----------------------
 
181
======================
194
182
 
195
183
Because the Bazaar HTTP smart server is a WSGI application, it can be used with
196
184
any 3rd-party WSGI middleware or server that conforms the WSGI standard.  The
217
205
 
218
206
 
219
207
Pushing over ``bzr+http://``
220
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
208
----------------------------
221
209
 
222
210
It is possible to allow pushing data over the http smart server. The
223
211
easiest way to do this, is to just supply ``readonly=False`` to the
232
220
writable server, and plain HTTP allow read-only access.
233
221
 
234
222
 
235
 
..
 
223
.. 
236
224
   vim: ft=rst tw=74 et