Skip to content

Instantly share code, notes, and snippets.

@ChrisBuchholz
Created October 3, 2012 18:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ChrisBuchholz/3828799 to your computer and use it in GitHub Desktop.
var development = {
env : global.process.env.NODE_ENV || 'development',
port: 8000,
proxy_routes: {
'localhost/events': '127.0.0.1:8002',
'localhost': '127.0.0.1:8001'
}
};
var production = {
env : global.process.env.NODE_ENV || 'production',
port: 80,
proxy_routes: {
'sewe.jit.su/events': '127.0.0.1:8002',
'sewe.jit.su': '127.0.0.1:8001'
}
};
exports.Config = global.process.env.NODE_ENV === 'production' ? production : development;
var http = require('http'),
proxy = require('http-proxy'),
faye = require('faye'),
// configuration
config = require('./config').Config;
/**
* la proxy
**/
proxy.createServer({ router: config.proxy_routes }).listen(config.port);
/**
* la website
**/
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
res.end();
}).listen(8001);
/**
* la event server
**/
var eventServer = new faye.NodeAdapter({ mount: '/', timeout: 45 }).listen(8002);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment