Deploying Express.js on Cloud9

Express.js (and probably most of other servers on Cloud 9) are being shielded by Cloud9 proxy. You usually cannot access them directly.
Anyway, according the Cloud9’s helping artice Can I use Cloud9 to do X the solution is following:
Start the ExpressJS to listen on Local IP and Local PORT, which are available, to start Express to listen use this:

// Cloud9 specific - needs to use defined port to listen
console.log("Starting to listen. ")

app.listen(process.env.PORT, process.env.IP);

You can then start Express.js normally like:

node myserver.js

I am starting server usually in new terminal window in Cloud9 and use bottom mini-terminal for tests, like:

markcz@demo-project:~/597752 (master) $ wget http://$IP:$PORT/getangularusers
--2013-09-11 07:06:12--
Connecting to connected.
HTTP request sent, awaiting response... 200 OK
Length: 14 [text/html]
Saving to: “getangularusers.1”

100%[==============>] 14 –.-K/s in 0s

2013-09-11 07:06:12 (1.08 MB/s) – “getangularusers.1” saved [14/14]

Which successfully downloaded the response from private binding fine.

To test public available uri, you can easily open web browser using following format:

My rest GET api path is /getangularusers and in my case it is publicised as

You cannot go inside C9 on different port then standard 80. And its being redirected to your local binding.

Please notice, that I am talking about standard HTTP port (80), in preview, you can get direct links to files hosted on Cloud9, but these are NOT your HTML pages hosted on a web server (Express).



I am going to describe in next article how to conigure static routing in Express to host your HTML files.


1. Use Cloud9 predefined IP and PORT to point where Express is going to listen

2. To access from outside of Cloud9, use standard HTTP on 80, and with 3rd domain like hostname