Created
August 1, 2012 20:00
-
-
Save toranb/3230184 to your computer and use it in GitHub Desktop.
Express and Apache
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 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