diff --git a/lib/http-server.js b/lib/http-server.js index dfe4c474..d732743e 100644 --- a/lib/http-server.js +++ b/lib/http-server.js @@ -181,6 +181,15 @@ function HttpServer(options) { if (options.timeout !== undefined) { this.server.setTimeout(options.timeout); } + + if (typeof options.proxy === 'string') { + this.server.on('upgrade', function (request, socket, head) { + proxy.ws(request, socket, head, { + target: options.proxy, + changeOrigin: true + }); + }); + } } HttpServer.prototype.listen = function () {