Skip to content

Instantly share code, notes, and snippets.

@nazomikan nazomikan/app1.js
Last active Jan 2, 2016

Embed
What would you like to do?
var http = require("http")
, server
;
server = http.createServer(function (req, res) {
res.writeHead(200);
res.end("<html><body><p>hi i am hidakaya</p></body></html>");
});
module.exports = server;
var http = require("http")
, server
;
server = http.createServer(function (req, res) {
res.writeHead(200);
res.end("<html><body><p>hi i am nazomikan</p></body></html>");
});
module.exports = server;
require('http').createServer(function(req, res) {
var hostname
, server1 = require('path/to/app1')
, server2 = require('path/to/app2')
;
if(!req.headers.host) {
return sendNotFound(res);
}
hostname = req.headers.host.split(":")[0];
switch (hostname) {
case "hoge-iam-hidakaya.xxx.com":
server1.emit('request', req, res);
break;
case "hoge-iam-nazomikan.xxx.com":
server2.emit('request', req, res);
break;
default:
sendNotFound(res);
break;
}
}).listen(3050);
function sendNotFound(res) {
res.writeHead(404);
res.end();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.