justcoding121 / titanium-web-proxy

A cross-platform asynchronous HTTP(S) proxy server in C#.
MIT License
1.93k stars 618 forks source link

way to use any other gateway without using default gateway in the computer #779

Open asinthe1 opened 4 years ago

asinthe1 commented 4 years ago

Is there any option to use another gateway for the proxy server without using the default gateway in windows

thanks

honfika commented 4 years ago

Yes, you can set any upstream proxy... you don't have to use the windows proxy settings. Moreover you can use different upsteream proxy for each request (for example by url or for load balancing reason)

asinthe1 commented 4 years ago

thanks for the quick reply can you please direct me to sample code

thanks and best regards

honfika commented 4 years ago

You can find the sample code here: https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs

Check the following properties: UpStreamHttpProxy, UpStreamHttpsProxy, GetCustomUpStreamProxyFunc

asinthe1 commented 4 years ago

Thanks for your reply i try like this var proxyServer = new ProxyServer(); proxyServer.UpStreamHttpProxy = new ExternalProxy("192.168.1.2", 808); proxyServer.UpStreamHttpsProxy = new ExternalProxy("192.168.1.2", 808);

its works fine for all traffic but if i want external proxy for specific sites for eg: facebook.com how to implement that i try OnRequest method like this if (e.HttpClient.Request.RequestUri.AbsoluteUri.Contains("facebook.com")) { e.CustomUpStreamProxy = new ExternalProxy("192.168.1.12", 808); }

then its not working is there any option to do that

and is there any option to use a gateway instead of proxy

thank you very much and best regards

honfika commented 4 years ago

Is your code at least called?

asinthe1 commented 4 years ago

yes its called i try in debug mode and object e.CustomUpStreamProxy has new value as well