连接到代理而不是本地Web服务器(不绕过代理) [英] Connect to proxy than local web server (without bypassing proxy)
问题描述
我正在运行本地网络服务器,我正在尝试与网络上的代理建立连接,而不是向本地网络服务器发出请求。  我认为以下代码会阻止代理在本地连接上被绕过,但是当我在我的localhost上执行
'isBypassed'检查时,它始终为True。 我需要采取哪些步骤才能在本地成功"取消"代理? 我可以修改byPassList以排除本地资源吗?
[code]
C#
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(" http://127.0.0.1:8080 / index.php");
$
request.Method =" GET";
WebProxy proxy = new WebProxy(" someip","somport"); //其中someip =一个ip地址,someport =一个端口(有效代理)
proxy.BypassProxyOnLocal = false; //无法解决我的问题
request.Proxy = proxy;
Console.WriteLine(proxy.IsBypassed(new Uri(" http://127.0.0.1) :8080 / index.php的")));       //说'真'
//通过获取页面验证连接(有效,但没有代理连接)
HttpWebResponse response =(HttpWebResponse)请求.GetResponse();
$
Console.WriteLine(response.StatusCode);
     
StreamReader reader = new StreamReader(response.GetResponseStream(),Encoding.UTF8);
$
string result = reader.ReadToEnd();
reader.Close();
response.Close();
[/ code]
似乎在某处无论什么地方绕过代理都是硬编码的。
提问是没有意义的127.0.0.1的代理,因为它是代理服务器的本地代理,它永远不会找到返回计算机的方式。
 
I have a local webserver running and I am trying to establish a connection to a proxy on the web, than make a request to the local webserver. The following code I thought would stop the proxy from being bypassed on local connections but when I do the 'isBypassed' check on my localhost it comes up as True always. What steps do I need to take to successfully 'unbypass' proxies locally? Can i modify the byPassList to exclude local resources?
[code]
C#
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:8080/index.php");
request.Method = "GET";
WebProxy proxy = new WebProxy("someip", "somport"); //where someip = an ip address, and someport = a port (valid proxy)
proxy.BypassProxyOnLocal = false; //doesn't solve my problem
request.Proxy = proxy;
Console.WriteLine(proxy.IsBypassed(new Uri("http://127.0.0.1:8080/index.php"))); //says 'True'
//verify connection by getting the page (works but no proxy connection)
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.WriteLine(response.StatusCode);
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
string result = reader.ReadToEnd();
reader.Close();
response.Close();
[/code]
It seems like it is hard coded somewhere to bypass the proxy locally always no matter what...
It makes no sense to ask a proxy for 127.0.0.1 since that would be local to the proxy server, it'll never find the way back to your computer.
这篇关于连接到代理而不是本地Web服务器(不绕过代理)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!