简体   繁体   English

C#中的HTTP代理服务器

[英]HTTP Proxy server in C#

My company is experimenting with writing a proxy server using the .NET Fx 3.5 and C#. 我的公司正在尝试使用.NET Fx 3.5和C#编写代理服务器。 From our research I have read that HttpListener is not a good candidate for a proxy server though I am unsure as to why. 从我们的研究中我已经读过HttpListener不是代理服务器的好选择,尽管我不确定为什么。

We are currently working with the Mentalis proxy example source code though that will involve, among other things, implementing our own logging and performance counters. 我们目前正在使用Mentalis代理示例源代码,但其中包括实现我们自己的日志记录和性能计数器。 Using HttpListener will wrap Http.sys which will give us some of the performance statistics we require out of the box. 使用HttpListener将包装Http.sys,它将为我们提供一些开箱即用的性能统计信息。

So why is HttpListener a bad candidate for HTTP proxy work? 那么为什么HttpListener是HTTP代理工作的不良候选者呢?

(And yes we are considering Squid 3.1 by writing or configuring an ICAP server as well.) (是的,我们也通过编写或配置ICAP服务器来考虑Squid 3.1。)

HttpListener is in .NET to provide a major building block for a simple HTTP server. HttpListener在.NET中为简单的 HTTP服务器提供了一个主要的构建块。 Where simple includes not supporting high operation rates. 简单包括不支持高运营率。

Typically HTTP proxies need to be very low overhead to support many concurrent connections as well as providing the proxy's function (which depends on the type of proxy). 通常,HTTP代理需要非常低的开销来支持许多并发连接以及提供代理的功能(这取决于代理的类型)。

Proxies are detailed in RFC 2616 §8.1.3 ) and that immediately provides one item that (if I understand HttpListener correctly) is not possible: RFC2616§8.1.3中详细介绍了代理,并立即提供了一个项目(如果我正确理解HttpListener)是不可能的:

The proxy server MUST signal persistent connections separately with its clients and the origin servers (or other proxy servers) that it connects to. 代理服务器必须分别与其客户端和它连接的源服务器(或其他代理服务器)发信号通知持久连接。 Each persistent connection applies to only one transport link. 每个持久连接仅适用于一个传输链路。

You might also consider that the windows port of nginx was released a few days ago. 您可能还会考虑几天前发布的nginx的Windows端口。 Many sites that have squid and varnish experience are very pleased after converting to nginx. 许多拥有鱿鱼和清漆经验的网站在转换为nginx后非常高兴。 Then there is always whatever MS is calling ISA server these days. 那么这些天MS总是会调用ISA服务器。

Gone off to look at the Mentalis code now :D 现在看看Mentalis代码:D

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM