//Chat from http://michieldemey.be/blog/node-js-and-socket-io-a-basic-chat-application-using-websockets/ var http = require('http'), httpProxy = require('http-proxy'), express = require('express'); // create a server var app = express(); var proxy = httpProxy.createProxyServer({ ws: true }); // proxy HTTP GET / POST app.get('/socket.io/*', function(req, res) { console.log("proxying GET request", req.url); proxy.web(req, res, { target: 'http://localhost:8081'}); }); app.post('/socket.io/*', function(req, res) { console.log("proxying POST request", req.url); proxy.web(req, res, { target: 'http://localhost:8081'}); }); // Proxy websockets app.on('upgrade', function (req, socket, head) { console.log("proxying upgrade request", req.url); proxy.ws(req, socket, head); }); // serve static content app.use('/', express.static(__dirname + "/public")); app.listen(8080);