1 var http = require('http'), httpProxy = require('http-proxy');
3 var backend_nginx = new httpProxy.HttpProxy({ target: { host: 'localhost', port: 81 } });
4 var backend_socketio = new httpProxy.HttpProxy({ target: { host: 'localhost', port: 82 }});
6 // Redirect socket.io requests to socket.io and static content to nginx
7 var server = http.createServer(function(req, res) {
8 if(req.url.match(/^\/socket\.io\//)) {
9 backend_socketio.proxyRequest(req, res);
11 backend_nginx.proxyRequest(req, res);
15 // Redirect websocket requests to the socket.io server
16 server.on('upgrade', function(req, socket, head) {
17 backend_socketio.proxyWebSocketRequest(req, socket, head);