Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 116 lines (76 sloc) 2.521 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
e9fb43a James Halliday bump to 0.0.2 for websocket-capable
authored
10 Bouncy is websocket-capable.
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
92d290b James Halliday s/methods/bouncy(cb)/
authored
58 bouncy(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
63 Your callback `cb` will get these arguments:
fe380a5 James Halliday documented the sugar and a bump to 0.0.1
authored
64
65 req
66 ---
67
68 The node http module request object.
69
024af40 James Halliday drop addHeader in favor of opts.headers
authored
70 bounce(stream, opts={})
71 -----------------------
fe380a5 James Halliday documented the sugar and a bump to 0.0.1
authored
72
73 Call this function when you're ready to bounce the request to a stream.
74
75 The exact request that was received will be written to `stream` and future
76 incoming data will be piped to and from it.
77
024af40 James Halliday drop addHeader in favor of opts.headers
authored
78 You can specify header fields to insert into the request with `opts.headers`.
79
2aab73a James Halliday bump and docs for x-forwarded headers
authored
80 By default, `"x-forwarded-for"`, `"x-forwarded-port"`, and `"x-forwarded-proto"`
81 are all automatically inserted into the outgoing header.
024af40 James Halliday drop addHeader in favor of opts.headers
authored
82
83 bounce(port, ...), bounce(host, port, ...)
84 ------------------------------------------
fe380a5 James Halliday documented the sugar and a bump to 0.0.1
authored
85
86 These variants of `bounce()` are sugar for
87 `bounce(net.createConnection(port))`
88 and
89 `bounce(net.createConnection(port, host))`.
90
6a12ded James Halliday note about opts.host, opts.port
authored
91 Optionally you can pass port and host keys to `opts` and it does the same thing.
92
024af40 James Halliday drop addHeader in favor of opts.headers
authored
93 bounce.respond()
94 ----------------
aec7719 James Halliday notes about bounce.respond()
authored
95
96 Return a new HTTP response object for the request.
97 This is useful if you need to write an error result.
98
0a8d54e James Halliday initial thing, seems to work
authored
99 install
100 =======
101
102 With [npm](http://npmjs.org), do:
103
104 npm install bouncy
105
122eb00 James Halliday notes about bouncy the command
authored
106 to install as a library or
107
108 npm install -g bouncy
109
110 to get the command-line tool.
111
0a8d54e James Halliday initial thing, seems to work
authored
112 license
113 =======
114
115 MIT/X11
Something went wrong with that request. Please try again.