mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Re-added previous description
This commit is contained in:
parent
ee6bbe0024
commit
603106a13d
19
README.md
19
README.md
@ -413,6 +413,25 @@ httpProxy.createServer(
|
|||||||
## Proxying WebSockets
|
## Proxying WebSockets
|
||||||
Websockets are handled automatically when using `httpProxy.createServer()`, however, if you supply a callback inside the createServer call, you will need to handle the 'upgrade' proxy event yourself. Here's how:
|
Websockets are handled automatically when using `httpProxy.createServer()`, however, if you supply a callback inside the createServer call, you will need to handle the 'upgrade' proxy event yourself. Here's how:
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
....
|
||||||
|
};
|
||||||
|
|
||||||
|
var server = httpProxy.createServer(
|
||||||
|
callback/middleware,
|
||||||
|
options
|
||||||
|
);
|
||||||
|
|
||||||
|
server.listen(port, function() { ... });
|
||||||
|
server.on('upgrade', function(req, socket, head) {
|
||||||
|
server.proxy.proxyWebSocketRequest(req, socket, head);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
If you would rather not use createServer call, and create the server that proxies yourself, see below:
|
||||||
|
|
||||||
``` js
|
``` js
|
||||||
var http = require('http'),
|
var http = require('http'),
|
||||||
httpProxy = require('http-proxy');
|
httpProxy = require('http-proxy');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user