How to spawn multiple instances of node.js on one machine to listen for different subdomains? -


this question has answer here:

for subdomain

a.abc.com     b.abc.com     c.abc.com 

i want run same duplicate of node.js script them. have 1 machine unfortunately. can suggest how may overcome this?

if have 3 "handlers", ie function (req, res) signature, can following on single server:

http.createserver(function (req, res) {   switch (url.parse(req.url).hostname) {     case 'a.abc.com':       handlera(req, res)       break     case 'b.abc.com':       handlerb(req, res)       break     case 'c.abc.com':       handlerc(req, res)       break     default:       res.statuscode = 404       res.end()       break   } }) 

you don't need reverse proxy unless need every handler on own process, ie if have lot of load


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -