node-http-mitm-proxy icon indicating copy to clipboard operation
node-http-mitm-proxy copied to clipboard

Is there any support for upstream proxy?

Open YafimK opened this issue 7 years ago • 3 comments

Hi, is there a configuration i should use when using this behind corporate proxy?

YafimK avatar Oct 22 '18 04:10 YafimK

If you are using node 12 or above, you can use https://github.com/gajus/global-agent by setting an environment variable:

export GLOBAL_AGENT_HTTP_PROXY=http://corp.proxy:8080

Code sample:

require('global-agent/bootstrap');

const Proxy = require('http-mitm-proxy');
const proxy = Proxy();

proxy.listen({ port: 8081 });

dave-irvine avatar Dec 27 '19 13:12 dave-irvine

could you add a context function or per request to set the proxy? because for example, we choose the proxy based on the destination URL, now we are putting all de login onRequest, and making the request via Axios, maybe is better to incorporate this feature into the proxy. Thanks.

ctaity avatar Apr 18 '22 03:04 ctaity

This seems like a better solution to me because you don't patch you global agent and can still make non-proxied requests elsewhere in your node app.

toniopelo avatar Dec 07 '23 11:12 toniopelo