Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single node.js http server accepting connections on multiple hostnames

Tags:

node.js

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

like image 824
yojimbo87 Avatar asked Oct 12 '22 13:10

yojimbo87


1 Answers

This should be possible with the 'vhost' middleware of ConnectJS:

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

Those docs are rather lacking, but looks like the ever-prolific TJ has an example here:

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

like image 60
Mike Repass Avatar answered Nov 15 '22 12:11

Mike Repass