Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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