Skip to content

Changing agent proxy on working proxy server #106

@d0c3ntOS

Description

@d0c3ntOS

I have couple of proxy around the world. I want change proxy when I know URL of request.

I use "https-proxy-agent" - https://www.npmjs.com/package/https-proxy-agent

I try change proxy.httpsAgent, closed server (proxy.close()) and strart again (proxy.listen({....})) my proxy server but this method don't work.


proxy.onRequest(function(ctx, callback) {
    ctx.use(Proxy.gunzip);

    console.log("--URL:",ctx.clientToProxyRequest.url);
    dbLib.getProxy(ctx.clientToProxyRequest.url, function() {
        if (global.proxy.length > 5){
            proxy.close();
            myproxy = process.env.http_proxy || 'http://'+global.proxy+':3128';
            myAgent = new HttpsProxyAgent(myproxy);
            proxy.httpsAgent = myAgent;
            proxy.httpAgent = myAgent;
            proxy.listen({port: 8800,  forceSNI: true});
            proxy.httpsAgent = myAgent;
            proxy.httpAgent = myAgent;
        }
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions