using node-http-proxy question

79 views
Skip to first unread message

john.tiger

unread,
Jul 7, 2013, 1:52:36 PM7/7/13
to nod...@googlegroups.com
we have successfully used http-proxy to allow multiple domains on a
single server routing incoming to a respective port and node app using
proxy-table.
ie:
'app1.com' : '127.0.0.1:8080' -> node app running on 8080
'app2.com' : '127.0.0.1:8081' -> node app running on 8081


How do we use proxy-table to route to a simple index.html files (single
page apps) which are not running as node apps on a specific port ?

http://app1.com -> /var/local/app1/index.html
http://app2.com -> /var/local/app2/index.html

and from there the single page app actually uses ajax calls to a restify
instance for REST db calls - that part is running okay on a test server.

what obvious thing am I missing here ? thks




Floby

unread,
Jul 8, 2013, 3:30:53 AM7/8/13
to nod...@googlegroups.com
node-http-proxy only proxies to other http servers. It does not serve content itself, unless you implement it.
IIRC you can use http-proxy as a connect middleware. From there you could implement a drop-in replacement with a server with 2 middlewares. The first one serving static content. and the second one running http-proxy.

TigerNassau

unread,
Jul 8, 2013, 10:53:34 AM7/8/13
to nod...@googlegroups.com
Thks, yeah i realized we need to run node-statc to serve basic pages. Somehow seems like a lot of node instances to run - one for proxy, one for restify, and another for static - but seems to work.

Sent from my LG Mobile

Floby <floren...@gmail.com> wrote:

>--
>--
>Job Board: http://jobs.nodejs.org/
>Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>You received this message because you are subscribed to the Google
>Groups "nodejs" group.
>To post to this group, send email to nod...@googlegroups.com
>To unsubscribe from this group, send email to
>nodejs+un...@googlegroups.com
>For more options, visit this group at
>http://groups.google.com/group/nodejs?hl=en?hl=en
>
>---
>You received this message because you are subscribed to the Google Groups "nodejs" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
>For more options, visit https://groups.google.com/groups/opt_out.
>
>

Mark Hahn

unread,
Jul 8, 2013, 2:15:57 PM7/8/13
to nod...@googlegroups.com
I highly recommend nginx.  Easy to use and is faster at proxying than node.  Node and Nginx work together beautifully.

Pedro Teixeira

unread,
Jul 8, 2013, 5:05:13 PM7/8/13
to nod...@googlegroups.com
One observation: Nginx doesn't allow everything that Node does, limiting services exposed through it. For instance, Nginx can't handle streaming requests, requiring that the request ended before forwarding it to Node, which in our case made is opt for HAProxy. Not everyone has this case, but it was very important for us and sticking with Nginx would have had involved painful workarounds.

-- 
Pedro

john.tiger

unread,
Jul 9, 2013, 12:27:22 PM7/9/13
to nod...@googlegroups.com
On 07/08/2013 03:05 PM, Pedro Teixeira wrote:
One observation: Nginx doesn't allow everything that Node does, limiting services exposed through it. For instance, Nginx can't handle streaming requests, requiring that the request ended before forwarding it to Node, which in our case made is opt for HAProxy. Not everyone has this case, but it was very important for us and sticking with Nginx would have had involved painful workarounds.

agree, as well as keeping common node/js constructs.  Still not sure running all the separate node instances (proxy, restify for each app, node-static for each app) is the most efficient. 
Reply all
Reply to author
Forward
0 new messages