Skip to content

Commit 03dbe11

Browse files
committed
add "with custom server logic" to the "Proxying WebSockets" section of the readme.md
1 parent 8a88774 commit 03dbe11

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
@@ -444,6 +444,34 @@ server.on('upgrade', function(req, socket, head) {
444444
server.listen(8080);
445445
```
446446

447+
### with custom server logic
448+
449+
``` js
450+
var httpProxy = require('http-proxy')
451+
452+
var server = httpProxy.createServer(function (req, res, proxy) {
453+
//
454+
// Put your custom server logic here
455+
//
456+
proxy.proxyRequest(req, res, {
457+
host: 'localhost',
458+
port: 9000
459+
});
460+
})
461+
462+
server.on('upgrade', function(req, socket, head) {
463+
//
464+
// Put your custom server logic here
465+
//
466+
proxy.proxyWebSocketRequest(req, socket, head, {
467+
host: 'localhost',
468+
port: 9000
469+
});
470+
});
471+
472+
server.listen(8080);
473+
```
474+
447475
### Configuring your Socket limits
448476

449477
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)