Merge pull request #332 from ramitos/patch-1

add "with custom server logic" to the "Proxying WebSockets" section of the readme
This commit is contained in:
Charlie Robbins 2013-03-08 21:45:30 -08:00
commit eee6babc98

View File

@ -463,6 +463,34 @@ server.on('upgrade', function(req, socket, head) {
server.listen(8080); server.listen(8080);
``` ```
### with custom server logic
``` js
var httpProxy = require('http-proxy')
var server = httpProxy.createServer(function (req, res, proxy) {
//
// Put your custom server logic here
//
proxy.proxyRequest(req, res, {
host: 'localhost',
port: 9000
});
})
server.on('upgrade', function(req, socket, head) {
//
// Put your custom server logic here
//
proxy.proxyWebSocketRequest(req, socket, head, {
host: 'localhost',
port: 9000
});
});
server.listen(8080);
```
### Configuring your Socket limits ### Configuring your Socket limits
By default, `node-http-proxy` will set a 100 socket limit for all `host:port` proxy targets. You can change this in two ways: By default, `node-http-proxy` will set a 100 socket limit for all `host:port` proxy targets. You can change this in two ways: