Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 131 lines (86 sloc) 3.212 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
a2e3243 @substack initial https mode with readme notes
authored
10 Bouncy is websocket and tls (https) capable.
e9fb43a @substack bump to 0.0.2 for websocket-capable
authored
11
f58313d @substack silly github, why you gotta emailify my semvers?
authored
12 Bouncy 0.0.4 is [faster than http-proxy 0.7.3](https://gist.github.com/1275259) in
793c24e @substack fix a broken link
authored
13 [this benchmark](https://github.com/substack/bouncy/tree/master/bench).
3b009d8 @substack link to the benchmark
authored
14
82eae2f @substack pix
authored
15 ![trampoline](http://substack.net/images/trampoline.png)
16
0a8d54e @substack initial thing, seems to work
authored
17 example
18 =======
19
ff8c99e @substack route example
authored
20 route.js
21 --------
22
23 Route requests based on the host field
24
25 ````javascript
26 var bouncy = require('bouncy');
27
28 bouncy(function (req, bounce) {
29 if (req.headers.host === 'beep.example.com') {
30 bounce(8001);
31 }
ef9db01 @substack fixed a typo in the route example
authored
32 else if (req.headers.host === 'boop.example.com') {
ff8c99e @substack route example
authored
33 bounce(8002)
34 }
35 }).listen(8000);
36 ````
37
122eb00 @substack notes about bouncy the command
authored
38 command-line
39 ============
0a8d54e @substack initial thing, seems to work
authored
40
122eb00 @substack notes about bouncy the command
authored
41 Just create a `routes.json` file like this:
0a8d54e @substack initial thing, seems to work
authored
42
43 ````javascript
122eb00 @substack notes about bouncy the command
authored
44 {
45 "beep.example.com" : 8000,
46 "boop.example.com" : 8001
47 }
0a8d54e @substack initial thing, seems to work
authored
48 ````
49
122eb00 @substack notes about bouncy the command
authored
50 Then point the `bouncy` command at this `routes.json` file and give it a port to
51 listen on:
52
53 bouncy routes.json 80
54
55 The `routes.json` file should just map host names to host/port combos.
56 Use a colon-separated string to specify a host and port in a route.
4c2fd12 @substack send x-forwarded-for in the bouncy command-line client
authored
57
58 Use `""` for the host as a default route.
59
a2e3243 @substack initial https mode with readme notes
authored
60 bouncy(opts={}, cb)
61 ===================
fe380a5 @substack documented the sugar and a bump to 0.0.1
authored
62
aec7719 @substack notes about bounce.respond()
authored
63 `bouncy(cb)` returns a new net.Server object that you can `.listen()` on.
64
a2e3243 @substack initial https mode with readme notes
authored
65 If you specify `opts.key` and `opts.cert`, the connection will be set to secure
66 mode using tls. Do this if you want to make an https router.
67
aec7719 @substack notes about bounce.respond()
authored
68 Your callback `cb` will get these arguments:
fe380a5 @substack documented the sugar and a bump to 0.0.1
authored
69
70 req
71 ---
72
73 The node http module request object.
74
024af40 @substack drop addHeader in favor of opts.headers
authored
75 bounce(stream, opts={})
76 -----------------------
fe380a5 @substack documented the sugar and a bump to 0.0.1
authored
77
78 Call this function when you're ready to bounce the request to a stream.
79
80 The exact request that was received will be written to `stream` and future
81 incoming data will be piped to and from it.
82
024af40 @substack drop addHeader in favor of opts.headers
authored
83 You can specify header fields to insert into the request with `opts.headers`.
84
2aab73a @substack bump and docs for x-forwarded headers
authored
85 By default, `"x-forwarded-for"`, `"x-forwarded-port"`, and `"x-forwarded-proto"`
86 are all automatically inserted into the outgoing header.
024af40 @substack drop addHeader in favor of opts.headers
authored
87
60b99ae @substack docs about destroy and default to c.destroy() if no emitter specified
authored
88 You can pass in an EventEmitter on `opts.emitter` to listen for `"drop"` events
89 which occur when a `.write()` fails which happens with annoying frequency in
90 node v0.4.x.
91
92 If you pass in an emitter you'll get the connection object on `"drop"` events so
93 you can handle these yourself by writing an error message to the stream. If you
94 don't pass in an `opts.emitter`, the connection will be `.destroy()`ed.
95
024af40 @substack drop addHeader in favor of opts.headers
authored
96 bounce(port, ...), bounce(host, port, ...)
97 ------------------------------------------
fe380a5 @substack documented the sugar and a bump to 0.0.1
authored
98
99 These variants of `bounce()` are sugar for
100 `bounce(net.createConnection(port))`
101 and
102 `bounce(net.createConnection(port, host))`.
103
6a12ded @substack note about opts.host, opts.port
authored
104 Optionally you can pass port and host keys to `opts` and it does the same thing.
105
024af40 @substack drop addHeader in favor of opts.headers
authored
106 bounce.respond()
107 ----------------
aec7719 @substack notes about bounce.respond()
authored
108
109 Return a new HTTP response object for the request.
110 This is useful if you need to write an error result.
111
0a8d54e @substack initial thing, seems to work
authored
112 install
113 =======
114
115 With [npm](http://npmjs.org), do:
116
117 npm install bouncy
118
122eb00 @substack notes about bouncy the command
authored
119 to install as a library or
120
121 npm install -g bouncy
122
123 to get the command-line tool.
124
0a8d54e @substack initial thing, seems to work
authored
125 license
126 =======
127
128 MIT/X11
82eae2f @substack pix
authored
129
130 ![jumping](http://substack.net/images/jumping.png)
Something went wrong with that request. Please try again.