Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 101 lines (68 sloc) 1.981 kB
0a8d54e @substack initial thing, seems to work
authored
1 bouncy
2 ======
3
4 Bouncy uses node's http parser innards to bounce http requests around to where
96c27c8 @substack note about transparency
authored
5 they need to go in an entirely transparent way.
0a8d54e @substack initial thing, seems to work
authored
6
122eb00 @substack notes about bouncy the command
authored
7 Use bouncy as a load balancer or http host router, either programmatically or
8 with the simple command-line tool.
0a8d54e @substack initial thing, seems to work
authored
9
e9fb43a @substack bump to 0.0.2 for websocket-capable
authored
10 Bouncy is websocket-capable.
11
3b009d8 @substack link to the benchmark
authored
12 Bouncy is [faster than http-proxy@0.7.3](https://gist.github.com/1275259) in
13 [this benchmark](https://github.com/substack/bouncy/tree/bench).
14
0a8d54e @substack initial thing, seems to work
authored
15 example
16 =======
17
ff8c99e @substack route example
authored
18 route.js
19 --------
20
21 Route requests based on the host field
22
23 ````javascript
24 var bouncy = require('bouncy');
25
26 bouncy(function (req, bounce) {
27 if (req.headers.host === 'beep.example.com') {
28 bounce(8001);
29 }
ef9db01 @substack fixed a typo in the route example
authored
30 else if (req.headers.host === 'boop.example.com') {
ff8c99e @substack route example
authored
31 bounce(8002)
32 }
33 }).listen(8000);
34 ````
35
122eb00 @substack notes about bouncy the command
authored
36 command-line
37 ============
0a8d54e @substack initial thing, seems to work
authored
38
122eb00 @substack notes about bouncy the command
authored
39 Just create a `routes.json` file like this:
0a8d54e @substack initial thing, seems to work
authored
40
41 ````javascript
122eb00 @substack notes about bouncy the command
authored
42 {
43 "beep.example.com" : 8000,
44 "boop.example.com" : 8001
45 }
0a8d54e @substack initial thing, seems to work
authored
46 ````
47
122eb00 @substack notes about bouncy the command
authored
48 Then point the `bouncy` command at this `routes.json` file and give it a port to
49 listen on:
50
51 bouncy routes.json 80
52
53 The `routes.json` file should just map host names to host/port combos.
54 Use a colon-separated string to specify a host and port in a route.
55 Use `''` as a default route.
56
92d290b @substack s/methods/bouncy(cb)/
authored
57 bouncy(cb)
58 ==========
fe380a5 @substack documented the sugar and a bump to 0.0.1
authored
59
60 There is only one method, `bouncy(cb)`. Your callback `cb` will get these
61 arguments:
62
63 req
64 ---
65
66 The node http module request object.
67
68 bounce(stream)
69 --------------
70
71 Call this function when you're ready to bounce the request to a stream.
72
73 The exact request that was received will be written to `stream` and future
74 incoming data will be piped to and from it.
75
76 bounce(port), bounce(host, port)
77 --------------------------------
78
79 These variants of `bounce()` are sugar for
80 `bounce(net.createConnection(port))`
81 and
82 `bounce(net.createConnection(port, host))`.
83
0a8d54e @substack initial thing, seems to work
authored
84 install
85 =======
86
87 With [npm](http://npmjs.org), do:
88
89 npm install bouncy
90
122eb00 @substack notes about bouncy the command
authored
91 to install as a library or
92
93 npm install -g bouncy
94
95 to get the command-line tool.
96
0a8d54e @substack initial thing, seems to work
authored
97 license
98 =======
99
100 MIT/X11
Something went wrong with that request. Please try again.