hoodiehq/hoodie-server — pull request #230 by lupomontero (2014-02-12 15:53:37+00:00)
Title: Upgraded http-proxy version and fixed up nodejitsu_server

I was running into a few problems running a hoodie app on nodejitsu, namely getting the "admin" and "couch" subdomains to work as expected. Digging through the code I found that this particular case is handled in `lib/server/nodejitsu_server.js` and that the idea is to have a proxy server internally routing to `www`, `admin` and `couch` based on the domain name. But I realised that we were using an outdated version of the `http-proxy` module and that the implementation seemed incomplete.

I have updated `http-proxy` from 0.10.4 to 1.0.2 and refactored `nodejitsu_server` accordingly. Before going ahead with this I checked to see if `http-proxy` was being used anywhere else but doesn't seem to be the case, so this change should only affect the nodejitsu scenario.

I also realised that `nodejitsu_server` was getting loaded after `hoodieServer `, and this was causing the `www` server to listen on the public port before the proxy could get a chance to bind to it. So external requests were always being handled by `www`. I have swapped the order in which these get loaded in `lib/index.js` and this seems to do the trick.

I have (not thoroughly) tested this on nodejitsu and seems to work ok so far: I can get to the `www`, `admin` and `couch` subdomains!

This should fix #31 and also make it trivial to fix #27