簡易版です。https://gist.github.com/novi/1830085
を参考にさせていただきました。
httpd.conf
Listen 8081
NameVirtualHost *:8081
<VirtualHost *:8081>
DocumentRoot /path/
ServerName www.example1.com
ServerAlias example1.com *.example1.com
</VirtualHost>
<VirtualHost *:8081>
DocumentRoot /path/
ServerName www.example2.com
ServerAlias example2.com *.example2.com
</VirtualHost>
http-proxy.js
var http = require('http');
var httpProxy = require('http-proxy');
var normalProxy = new httpProxy.createProxyServer({
target: {
host: 'localhost',
port: 8081
}});
var webSocketProxy = new httpProxy.createProxyServer({
target: {
host: 'localhost',
port: 3000
}});
var server = http.createServer(function ( req, res ) {
if (req.headers.host == 'example1.com') {
normalProxy.web( req, res );
} else if (req.headers.host == 'example2.com') {
webSocketProxy.web( req, res );
} else {
res.writeHead(404);
res.end();
}
});
server.on( 'upgrade', function( req, socket, head ) {
webSocketProxy.ws( req, socket, head );
});
server.listen(80);
console.log('It Works!');