Installation

When you sign up you will be provided with a unique username and password that you can use when configuring your proxy service in your application: 

  

http://username:password@proxy.quotaguard.com:9292

  


We recommend you store the connection string in an environment variable QUOTAGUARD_URL to maintain compatibility with platforms like Heroku and CloudControl.


You can test your proxy setup using curl:

 

$ curl -x username:password@proxy.quotaguard.com:9292 http://www.google.com/

 

Integration

You can use the standard HTTP library in Node.js but must ensure you correctly set the "Host" header to your target hostname, not the proxy hostname.

                

 

var http, options, proxy, url;

http = require("http");

url = require("url");

proxy = url.parse(process.env.QUOTAGUARD_URL);
target = url.parse("http://ip.jsontest.com/");

options = {
  hostname: proxy.hostname,
  port: proxy.port || 80,
  path: target.href,
  headers: {
    "Proxy-Authorization": "Basic " + (new Buffer(proxy.auth).toString("base64")),
    "Host" : target.hostname
  }
};

http.get(options, function(res) { 
  res.pipe(process.stdout);
  return console.log("status code", res.statusCode);  
});