Skip to content

Instantly share code, notes, and snippets.

@sergioramos
Created November 7, 2012 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergioramos/4032198 to your computer and use it in GitHub Desktop.
Save sergioramos/4032198 to your computer and use it in GitHub Desktop.
var proxy = new (require('http-proxy')).RoutingProxy(),
http = require('http')
var server = http.createServer(function (req, res, next) {
var port = someLogicToFigureOutWhichPort(req)
proxy.proxyRequest(req, res, {
host: 'localhost',
port: port
})
}).listen(1337)
server.on('upgrade', function(req, socket, head) {
proxy.proxyWebSocketRequest(req, socket, head)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment