Skip to content

Instantly share code, notes, and snippets.

@szimek
Created May 12, 2011 07:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save szimek/968073 to your computer and use it in GitHub Desktop.
Save szimek/968073 to your computer and use it in GitHub Desktop.
Basic static files server + reverse proxy for XMPP BOSH in NodeJS
var util = require('util'),
express = require('express'),
httpProxy = require('http-proxy');
var app = express.createServer(),
proxy = new httpProxy.HttpProxy();
app.configure(function() {
app.use(express.static(__dirname + "/public"));
});
app.configure("development", function () {
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.all('/http-bind', function(req, res) {
util.puts('Request successfully proxied: ' + req.url);
util.puts(JSON.stringify(req.headers, true, 2));
proxy.proxyRequest(req, res, {
host: 'localhost',
port: 5280
});
});
app.listen(8080);
util.puts("Server running at http://0.0.0.0:8080/ in " + app.set("env") + " mode.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment