开发者

Single node.js http server accepting connections on multiple hostnames

开发者 https://www.devze.com 2023-02-16 14:06 出处:网络
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.d开发者_运维知识库omain.com, x2.domain.com, .

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.d开发者_运维知识库omain.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.


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


It looks like it's not (natively) possible unless some kind of proxy or extra IP address for certain (sub)domains is used.

0

精彩评论

暂无评论...
验证码 换一张
取 消