Skip to content

Commit eee6bab

Browse files
committed
Merge pull request #332 from ramitos/patch-1
add "with custom server logic" to the "Proxying WebSockets" section of the readme
2 parents c6da760 + 03dbe11 commit eee6bab

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,34 @@ server.on('upgrade', function(req, socket, head) {
463463
server.listen(8080);
464464
```
465465

466+
### with custom server logic
467+
468+
``` js
469+
var httpProxy = require('http-proxy')
470+
471+
var server = httpProxy.createServer(function (req, res, proxy) {
472+
//
473+
// Put your custom server logic here
474+
//
475+
proxy.proxyRequest(req, res, {
476+
host: 'localhost',
477+
port: 9000
478+
});
479+
})
480+
481+
server.on('upgrade', function(req, socket, head) {
482+
//
483+
// Put your custom server logic here
484+
//
485+
proxy.proxyWebSocketRequest(req, socket, head, {
486+
host: 'localhost',
487+
port: 9000
488+
});
489+
});
490+
491+
server.listen(8080);
492+
```
493+
466494
### Configuring your Socket limits
467495

468496
By default, `node-http-proxy` will set a 100 socket limit for all `host:port` proxy targets. You can change this in two ways:

0 commit comments

Comments
 (0)