My end goal is to make node.js more cost effective per each server instance.
I’m not running a game or chat room but rather simple websites for customers. I would like to house multiple clients on a single server yet have multiple websites running off of port 80 using host header mapping. I would like to still use express as I’m doing but have it be more like a routing thing from port 80 to the other node apps if that is even possible. Node can be cheaper if its done in this way but currently its more expensive for my purposes as each customer would need their own box if running on port 80. Also, my motivation is to focus on node development but there must be a reason to do so in terms of cost.
I do this quite a lot for ASP.NET in Windows as IIS supports this out of the box and I know this is something normal for Apache as well.
Feel free to move this to another forum in stack exchange if this is not the right question or give constructive criticism rather than a random downvote. Thanks.
update
The approach I took was to use static hosting (via gatspy and s3) then an API instead that registered domains through post message from the client and API keys from the server and generates static sites periodically as sites change but thanks for all the suggestions!
In theory, you could build a pure-Node web server that emulated the functionality of Apache/Lighttpd/Nginx, but I wouldn’t recommend it. In fact, for serious production services, I’d recommend ALWAYS fronting your service with Nginx or an equivalent (see this and this).
Here’s how a simple Nginx config would work for two subservices exposed on port 80.
I’ve seen production boxes kernel panic because Node doesn’t throttle load by default and was prioritizing accepting new connections over handling existing requests – granted, it “shouldn’t” have crashed the kernel, but it did. Also, by running on port 3000, you can run your Node service as non-root with very few permissions (and still proxy it so that it appears to be on port 80). You can also spread load between multiple workers, serve statics, log requests, rewrite urls, etc, etc, etc. Nginx is very fast (much lighter than Apache). The overhead of same-box proxy forwarding is minimal and buys you so much functionality and robustness that it’s a slam dunk in my book. Even minor stuff, like – when I crash or overload my node service, do user get a black hole, or a “pardon our dust, our servers are being maintained” splash.