Using HOST header (or virtual hosts) to render different content from same app?


#1

We are wanting so much to move to Cloud9 and use it for all of our development projects. Our node.js apps use HOST header to determine which part of the app to render. On localhost right now we set up the /etc/hosts file with something line this:

127.0.0.1    www.domain.dev
127.0.0.1    admin.domain.dev
127.0.0.1    user1.domain.dev
127.0.0.1    user2.domain.dev

Every account / user gets their own sub-domain as you can see. On Cloud9, there isn’t the ability to use the HOST header so we can get our app to work in development. Is there a work-around to this that other customers use?

The other scenario is where we use Nginx as the reverse proxy in front of the Node.js process to route certain host domains like api.domain.dev or admin.domain.dev or *.domain.dev to the correct process port. Is this possible at all?

If none of the above are possible due to the fact that Cloud9 only exposes a single host at https://project-user.c9users.io then may I suggest something that Google uses with App Engine. They allow the ability to add custom sub-domain by separating the third-level domain with the string -dot- then they parse that in their backend code to get the project-user portion and enable the app to receive custom hostnames (not top level domain names). Plus this keeps the TLS/SSL working as needed.

For example, we could then be able to tell our development process to look for the host https://admin-dot-project-user.c9users.io to render the admin app or route to the correct process and port using Nginx.

I hope the above made some sense, and can you please tell me if anything is possible around this area. We really need to figure out if we should still keep evaluating Coud9 or move on as this is a great limitation. Most of our apps are multi-process and multi-host apps.

Thank you very much.


#2

Cloud9 should be forwarding the host header see How to host multiple websites in one server.
We use that to run cloud9 on cloud9 https://c9.io/blog/always-eat-your-own-dogfood/

Does it not work on your project?