Running node app behind a httpproxy

964 views
Skip to first unread message

José F. Romaniello

unread,
Aug 29, 2013, 6:52:19 AM8/29/13
to nod...@googlegroups.com

We are deploying our application to a new environment where it has to run behind an httpproxy.

We already know how to use http.request behind a proxy, but refactoring all our code and dependencies to work like that is very difficult. For now we monkey patched http.request and everything seems to work but we are not entirely happy with it.

I tried proxychains but couldn't make it work with node also read about connect - proxy but haven't tried yet.  Is something like this the right solution?

Thanks

Nathan Rajlich

unread,
Aug 29, 2013, 12:46:18 PM8/29/13
to nodejs

I've had good luck so far with creating `http.Agent` subclasses that transparently connect to your desired proxy. This way, it's only 1 option that needs to be added to your HTTP requests. In our app all HTTP requests are wrapped by another module, so that logic was already centralized so it was rather easy to add for all HTTP requests.

I've written a few modules for different proxy scenarios (I know there's others out there too, and mine are still missing some crucial features, like proxy authentication):


Cheers!

--
--
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.

john.tiger

unread,
Aug 29, 2013, 12:54:29 PM8/29/13
to nod...@googlegroups.com
have you tried node-http-proxy ? it's very good with a bunch of
examples - if you have a question after trying it, post it and maybe we
or someone else can help

José F. Romaniello

unread,
Aug 29, 2013, 12:55:11 PM8/29/13
to nod...@googlegroups.com
Hi Nathan, very nice, I'm actually doing something similar already using koichik/node-tunnel .. but because I don't want to patch my code and also the dependencies we have, we figure out this overriding http[s].request like this:

https://gist.github.com/jfromaniello/6380601

Not totally happy with this, but seems to work





2013/8/29 Nathan Rajlich <nat...@tootallnate.net>

José F. Romaniello

unread,
Aug 29, 2013, 12:56:50 PM8/29/13
to nod...@googlegroups.com
this is not what I want, node-http-proxy allows you to build reverse proxies and so on.. I'm looking for a transparent way to make requests from node behind a proxy


2013/8/29 john.tiger <john.tig...@gmail.com>
On 08/29/2013 04:52 AM, José F. Romaniello wrote:

We are deploying our application to a new environment where it has to run behind an httpproxy.

We already know how to use http.request behind a proxy, but refactoring all our code and dependencies to work like that is very difficult. For now we monkey patched http.request and everything seems to work but we are not entirely happy with it.

I tried proxychains but couldn't make it work with node also read about connect - proxy but haven't tried yet.  Is something like this the right solution?


have you tried node-http-proxy ?  it's very good with a bunch of examples - if you have a question after trying it, post it and maybe we or someone else can help
Thanks

--
--
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

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+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
--
--
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

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+unsubscribe@googlegroups.com.

Nathan Rajlich

unread,
Aug 29, 2013, 1:45:17 PM8/29/13
to nodejs
Ya, if you don't already have a centralized place where HTTP requests get created, then your monkey-patching technique is probably the easiest route to go.
Reply all
Reply to author
Forward
0 new messages