Created
May 12, 2011 07:06
-
-
Save szimek/968073 to your computer and use it in GitHub Desktop.
Basic static files server + reverse proxy for XMPP BOSH in NodeJS
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 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