Search code examples
node.jssquidrestify

How do you use node-restify clients through a HTTP forward proxy like Squid?


I can use Node.js to make HTTP requests through Squid with a little gymnastics of path vs URL handling and header alteration:

var http = require('http');
var host = "lvhubproxy01";

var options = {
  host: host,
  port: 3128,
  path: "http://images.joyent.com/images",
  headers: {
    Host: 'images.joyent.com'
  }
};

var req = http.request(options, function(res) {
  console.dir('STATUS: ' + res.statusCode);
  console.log('HEADERS: ' + JSON.stringify(res.headers));
});

req.end();

I would like to send node-restify requests through Squid as well, but I cannot find any indication of how to do this.

How do you use node-restify clients through a HTTP forward proxy like Squid?


Solution

  • You could have a look at using this wrapper: https://gist.github.com/jeffwhelpley/5417758 Not very clean, but perhaps it could help you out.