Skip to content

Instantly share code, notes, and snippets.

@dopa
Last active December 16, 2015 06:19
Show Gist options
  • Save dopa/5390532 to your computer and use it in GitHub Desktop.
Save dopa/5390532 to your computer and use it in GitHub Desktop.
Memecube - Nodeproxy server.js
var http = require('http'),
httpProxy = require('http-proxy');
//
// Create an instance of node-http-proxy
//
var proxy = new httpProxy.HttpProxy({
target: {
host: 'localhost',
port: 8124
}
});
var server = http.createServer(function (req, res) {
//
// Proxy normal HTTP requests
//
proxy.proxyRequest(req, res);
});
server.on('upgrade', function(req, socket, head) {
//
// Proxy websocket requests too
//
proxy.proxyWebSocketRequest(req, socket, head);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment