Skip to content

Instantly share code, notes, and snippets.

@toranb
Created August 1, 2012 20:00
Show Gist options
  • Select an option

  • Save toranb/3230184 to your computer and use it in GitHub Desktop.

Select an option

Save toranb/3230184 to your computer and use it in GitHub Desktop.
Express and Apache
var httpProxy = require('http-proxy');
var http = require('http');
var express = require('express');
httpProxy.createServer(function (req, res, proxy) {
var nodeVhosts = ["www.site.com"]
var host = req.headers['host'];
var port = nodeVhosts.indexOf(host) > -1
? 8080
: 9000;
proxy.proxyRequest(req, res, {host: 'localhost', port: port});
}).listen(8000);
var app = express();
var server = http.createServer(app);
var site = require('./site/app.js').site
app.use(express.vhost('www.site.com', site));
server.listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment