Merge pull request #349 from jamie-stackhouse/patch-1

Misleading documentation for Websockets via .createServer
This commit is contained in:
Charlie Robbins 2013-03-08 20:49:05 -08:00
commit c686ac7b01

View File

@ -411,7 +411,26 @@ httpProxy.createServer(
``` ```
## Proxying WebSockets ## Proxying WebSockets
Websockets are handled automatically when using `httpProxy.createServer()`, but if you want to use it in conjunction with a stand-alone HTTP + WebSocket (such as [socket.io][5]) server 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'),