Created
September 26, 2017 02:56
-
-
Save dmohs/00bc372818e490c31a0d472a2208a08f to your computer and use it in GitHub Desktop.
Minimal HTTP and Websocket proxy server in Node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const httpProxy = require('http-proxy'); | |
const proxy = new httpProxy.createProxyServer({ | |
target: { | |
host: 'notebook', | |
port: 8888 | |
} | |
}); | |
var proxyServer = http.createServer(function (req, res) { | |
proxy.web(req, res); | |
}); | |
proxyServer.on('upgrade', function (req, socket, head) { | |
proxy.ws(req, socket, head); | |
}); | |
proxyServer.listen(8888); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment