Learn how to route Node.js HTTP traffic through a QuotaGuard Static IP using the https-proxy-agent library.
npm install https-proxy-agentQUOTAGUARDSTATIC_URL=... node https.jsBe sure to set QUOTAGUARDSTATIC_URL to your HTTP proxy URL from the QuotaGuard Dashboard.
docker build -t qg-static-node-https-example .
docker run -e QUOTAGUARDSTATIC_URL=... qg-static-node-https-examplevar url = require('url');
var https = require('https');
var HttpsProxyAgent = require('https-proxy-agent');
// HTTP/HTTPS proxy to connect to
var proxy = process.env.QUOTAGUARDSTATIC_URL;
console.log('using proxy server %j', proxy);
// HTTPS endpoint for the proxy to connect to
var endpoint = 'https://ip.quotaguard.com';
console.log('attempting to GET %j', endpoint);
var options = url.parse(endpoint);
// create an instance of the `HttpsProxyAgent` class with the proxy server information
var agent = new HttpsProxyAgent(proxy);
options.agent = agent;
https.get(options, function (res) {
console.log('"response" event!', res.headers);
res.pipe(process.stdout);
});FROM node:latest
COPY https.js /app/https.js
WORKDIR /app/
RUN npm install https-proxy-agent
ENTRYPOINT [ "node", "https.js" ]