Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Using node behind firewall with HTTP_PROXY
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tauren Mills  
View profile  
 More options Jan 30 2012, 2:49 pm
From: Tauren Mills <tau...@groovee.com>
Date: Mon, 30 Jan 2012 11:49:23 -0800
Local: Mon, Jan 30 2012 2:49 pm
Subject: Using node behind firewall with HTTP_PROXY
Is there a way to get ALL outbound HTTP requests from node apps to use
the HTTP_PROXY environment variable? I'm behind a corporate firewall
and must go through a proxy.

In my own code, I can successfully get through the proxy by using
Mikeal's request:

var request = require('request');
request = request.defaults({proxy: process.env.HTTP_PROXY });
request.get({
  url: "http://google.com"

}, function(e,r,body) {

  if (body.indexOf('doctype')) {
    console.log("Loaded google.com");
  }
  else {
    console.log("Error loading google.com", e);
  }

});

But what about 3rd-party libs installed via NPM? Is there a way to get
them to recognize the HTTP_PROXY setting? Obviously, I can't hack all
of them to update request.get with my proxy setting. And some of them
don't use request. As you can see above, I've even setting a default
proxy in my app logic. But as I assumed, this doesn't pass through to
other libs. For instance, I'm trying to get this working with jsdom:

var request = require('request');
request = request.defaults({proxy: process.env.HTTP_PROXY });
var jsdom = require('jsdom');
jsdom.env("http://nodejs.org/dist/", [
  'http://code.jquery.com/jquery-1.5.min.js'
],
function(errors, window) {
  console.log("Window: ", window);
  if (errors) {
    console.log("Error: ",errors);
  }
  else {
    console.log("There have been", window.$("a").length, "nodejs
releases!");
  }

});

This results in:

Window:  undefined
Error occurred { [Error: connect ECONNREFUSED]
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect' }

There must be others building Node apps behind a proxy. How do you
deal with this?

Thanks!
Tauren


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Boris Simandoff  
View profile  
 More options Feb 23 2012, 7:53 am
From: Boris Simandoff <simand...@gmail.com>
Date: Thu, 23 Feb 2012 04:53:36 -0800 (PST)
Local: Thurs, Feb 23 2012 7:53 am
Subject: Re: Using node behind firewall with HTTP_PROXY
Unfortunately, I also couldn't find way to make JSDOM to use
http_proxy.
You can use "request" to download your html using proxy and submit the
body to jsdom:

request({ uri:'http://www.google.com' }, function (e, r, html) {
  if (e && r.statusCode !== 200) {
    console.log("Some error message");
  } else {
    jsdom.env({html: html, scripts: [__dirname + "/static/jq.js"]}, //
load local copy of jquery.js
       function (err, window) {
           var $ = window.jQuery;
           console.log($('body').html());
       });
  }

});

Cheers,
B Simandoff
On Jan 30, 9:49 pm, Tauren Mills <tau...@groovee.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »