Skip to content

Instantly share code, notes, and snippets.

@dmohs
Created September 26, 2017 02:56
Show Gist options
  • Save dmohs/00bc372818e490c31a0d472a2208a08f to your computer and use it in GitHub Desktop.
Save dmohs/00bc372818e490c31a0d472a2208a08f to your computer and use it in GitHub Desktop.
Minimal HTTP and Websocket proxy server in Node
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