james-proxy / james

Web Debugging Proxy Application
1.42k stars 126 forks source link

Allow configuring proxy for James to use #413

Open mhtvsSFrpHdE opened 5 years ago

mhtvsSFrpHdE commented 5 years ago

While connected to a VPN,
James use VPN to connect.
In this case if James required to connect directly that not use VPN,
have to disconnect VPN first.

Any plan to given a option that not use direct connect,
that to use another proxy as parent proxy?

mitchhentges commented 5 years ago

Hey! :wave: Got two questions:

Note: does James use the Windows system proxy in "Internet options"? FWIW, I frequently set that system proxy to point to James (localhost:1338), and James ignores it - my traffic doesn't loop in on itself. Instead, browser traffic gets sent to James, and James goes straight to the destination

asharron commented 5 years ago

Hey! I would like to have something like this too.

If you look at Charles, they have an option called external URL proxy settings where instead of Charles going straight to the destination, it routes it through whatever proxy url you give it. I'd like to have similar functionality for James since I am behind a corporate proxy that also requires authentication.

I wouldn't mind adding this functionality myself if you could give me a few pointers on how to get started. I'm pretty familiar with React + Redux, but not electron and how the project itself is setup.

mitchhentges commented 5 years ago

That would be awesome asharron! We have some docs for contributing, which should get you set up with a local build.

This feature might be a little tough to do, since you need to do:

I'd recommend looking at the logic for throttling network speed to see how we've configured hoxy in other ways.

A PR would be fantastic and appreciated! Feel free to set up a fancy new draft PR and asking any questions you might run into :)

asharron commented 5 years ago

So as an update, I figured out to use an external proxy with Hoxy. You can use an option called upstreamProxy when creating the server. To test this out, I added it to the opts object you create in proxy,.js and it worked fine.

The problem for me, however, is that I need to use authentication in order to use the external proxy. So instead of using the typical host:port format, I need to use origin%5CUsername:Password@host:port which it looks like Hoxy doesn't support at the moment, at least judging by the options given in the docs.

I'm going to see if I can find a way to enable this. I may have to submit a PR there first before this feature gets incorporated in James.

I'll keep you updated if I find anything.

mhtvsSFrpHdE commented 5 years ago

It was my mistake.
I did a test again and confirmed that James does connect directly instead of following system proxy.
This lead to another issue that,
if I want the James to connect directly and not to use VPN,
I have to disconnect the VPN first.

Just like the other mention,
a custom parent proxy would match the two case at the same time,
so can avoid repeat about connect and disconnect the VPN many times.

Although write scripts to manage VPN connection faster is not a bad idea.😅

asharron commented 5 years ago

Hey, I ran into some issues when implementing this feature, and I am actually leaving the role that I was going to add this feature for.

Because of this, I don't think I will be finishing the feature.

For someone who is looking to implement this, basically you would need to make a pull request to hoxy that allows you to add proxy credentials when you specify and upstream proxy.

This was a bit tricky for me since it involved understanding how proxy requests work with http headers (and also because the hoxy code base is a bit difficult to understand).

Once hoxy has that feature in it, then James would have the feature as well. A menu could then be added to toggle the credentials for the upstream proxy (could even maybe just have a config file for starters until getting around to creating a React component for it).

Hope this helps someone and sorry for not figuring it out!

mitchhentges commented 5 years ago

Thanks for taking a look Alex! This directions-for-next-dev comment is super awesome as well :100: you're a champ.

Good luck in your new role!