Last active
December 16, 2015 06:19
-
-
Save dopa/5390532 to your computer and use it in GitHub Desktop.
Memecube - Nodeproxy server.js
This file contains hidden or 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
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