Single node.js http server accepting connections over multiple host names

Is it possible to create a single http server in node.js that will accept connections on multiple host names? For example: I have a number of subdomains (x1.domain.com, x2.domain.com, ... xn.domain.com) associated with an IP address, and I want the node.js program to accept connections only on x1 .domain.com and x2.domain.com.

+4
source share
2 answers

This should be possible with ConnectJS vhost middleware:

http://senchalabs.github.com/connect/middleware-vhost.html

Those docs are rather missing, but it seems like the ever-growing TJ has an example:

https://github.com/LearnBoost/cluster/commit/7ede5b13a9b829ff25557ec0d6f483f6bd45ada8

+4
source

All Articles