此处将为大家介绍关于RabbIT4.9发布,Web代理服务器的详细内容,并且为您解答有关web代理服务器软件的相关问题,此外,我们还将为您介绍关于ASP.NETCore实现带认证功能的Web代理服务器
此处将为大家介绍关于RabbIT 4.9 发布,Web代理服务器的详细内容,并且为您解答有关web代理服务器软件的相关问题,此外,我们还将为您介绍关于ASP.NET Core 实现带认证功能的Web代理服务器、C#实现多线程的Web代理服务器实例、CshBBrain V2.0.0 版发布,WebSocket服务器、CshBBrain V2.0.1 发布,WebSocket服务器的有用信息。
本文目录一览:- RabbIT 4.9 发布,Web代理服务器(web代理服务器软件)
- ASP.NET Core 实现带认证功能的Web代理服务器
- C#实现多线程的Web代理服务器实例
- CshBBrain V2.0.0 版发布,WebSocket服务器
- CshBBrain V2.0.1 发布,WebSocket服务器
RabbIT 4.9 发布,Web代理服务器(web代理服务器软件)
RabbIT 是一个Web代理服务器,用来在一些慢速的网络(例如拨号网络)中加速网页的访问,主要功能有:
- 支持 gzip 的文本页面的压缩,压缩率可达 75%
- 对 JPEG 图片进行压缩,可减少图片大小 95%
- 广告过滤
- 删除背景图片
- 对页面和图片进行缓存
- 支持 Keep-Alive
- 简单易用但功能强大的配置
- 采用 Java 开发的多线程应用
- 模块化结构,利于扩展
- 完全兼容 HTTP/1.1
Changes:
1. It is now easier to use database resources in different parts of the proxy.
2. It is easier to use external jar files.
3. A problem with the HTTP header reader that could result in... a RequestLineTooLongException has been fixed
ASP.NET Core 实现带认证功能的Web代理服务器
引言
最近在公司开发了一个项目,项目部署架构图如下:
思路
如图中文本所述,公司大数据集群不允许直接访问外网,需要一个网关服务器代理请求,本处服务器A就是边缘代理服务器的作用。
通常技术人员最快捷的思路是在服务器A上部署IIS+Application Request Routing Module组件,或者配置由Nginx代理请求完成此次边缘代理服务器的功能。
-
服务器A需要定时访问外网云服务器将数据请求并保存到本地
-
代理服务器A集中管理云服务器B的基本身份认证凭据, 所以该代理服务器A在代理请求的时候需要发送认证凭据
关于web服务器定时任务功能实践,请参照技术博客;
关于基本身份认证的编程实践,请参照技术博客。
所以本处我们考虑利用ASP.NET Core实现一个带认证功能的代理服务器。
-
实现代理请求
-
代理请求的时候携带 基本身份认证凭据
编程实现
Install-Package Microsoft.AspNetCore.Proxy -Version 0.2.0
该中间件目前只有2个扩展方法,主要关注如下扩展方法:
// // 摘要: // Sends request to Remote Server as specified in options // // 参数: // app: // // options: // Options for setting port,host,and scheme public static IApplicationBuilder RunProxy(this IApplicationBuilder app,ProxyOptions options);
本次代理请求需要携带BA凭据,所以可在ProxyOptions参数设定基本身份认证Handler:
public void ConfigureServices(IServiceCollection services) { _remoteAccount = services.ConfigureOption<RemoteBasicAuth>(Configuration.GetSection("RemoteBasicAuth")); _proxyOption = services.ConfigureOption<ProxyOptions>(Configuration.GetSection("ProxyOptions")); // 从本地配置文件读取云服务器B的认证凭据,并设置基本身份认证Handler _proxyOption.BackChannelMessageHandler = new BasicAuthenticationClientHandler(_remoteAccount); ...... }
该云服务器B在部分页面【url以/eqids开头、api以/api/v1/eqids/】配置了BA认证:
所以本次我们使用了MapWhen条件中间件:
public void Configure(IApplicationBuilder app,Microsoft.AspNetCore.Hosting.IHostingEnvironment env,Microsoft.Extensions.Hosting.IApplicationLifetime appLifetime,ILoggerFactory loggerFactory) { ...... app.MapWhen(x=> x.Request.Path.Value.StartsWith(@"/eqids",StringComparison.OrdinalIgnoreCase) || x.Request.Path.Value.StartsWith(@"/api/v1/eqids",StringComparison.OrdinalIgnoreCase),builder => builder.RunProxy(_proxyOption)); ...... }
That‘s All. 以上程序部署到服务器A之后, 这样访问服务器A的部署网站, 等同于访问云服务器B的资源,服务器B对于内网来说是透明的。
本文期待以一种轻松、优雅的方式快速实现一个具备自定义消息处理能力的Web代理服务器。
----------如有问题请大胆斧正;你觉得文章对你有价值,请
C#实现多线程的Web代理服务器实例
本文实例讲述了C#实现多线程的Web代理服务器。分享给大家供大家参考。具体如下:
/** Proxy.cs: C# Programming Tips & Techniques by Charles Wright,Kris Jamsa Publisher: Osborne/McGraw-Hill (December 28,2001) ISBN: 0072193794 */ // Proxy.cs -- Implements a multi-threaded Web proxy server // // Compile this program with the following command line: // C:>csc Proxy.cs using System; using System.Net; using System.Net.sockets; using System.Text; using System.IO; using System.Threading; namespace nsproxyServer { public class ProxyServer { static public void Main (string [] args) { int Port = 3125; if (args.Length > 0) { try { Port = Convert.ToInt32 (args[0]); } catch { Console.WriteLine ("Please enter a port number."); return; } } try { // Create a listener for the proxy port TcpListener sockServer = new TcpListener (Port); sockServer.Start (); while (true) { // Accept connections on the proxy port. Socket socket = sockServer.AcceptSocket (); // When AcceptSocket returns,it means there is a connection. Create // an instance of the proxy server class and start a thread running. clsProxyConnection proxy = new clsProxyConnection (socket); Thread thrd = new Thread (new ThreadStart (proxy.Run)); thrd.Start (); // While the thread is running,the main program thread will loop around // and listen for the next connection request. } } catch (IOException e) { Console.WriteLine (e.Message); } } } class clsProxyConnection { public clsProxyConnection (Socket sockClient) { m_sockClient = sockClient; } Socket m_sockClient; //,m_sockServer; Byte [] readBuf = new Byte [1024]; Byte [] buffer = null; Encoding ASCII = Encoding.ASCII; public void Run () { string strFromClient = ""; try { // Read the incoming text on the socket/ int bytes = ReadMessage (m_sockClient,readBuf,ref strFromClient); // If it's empty,it's an error,so just return. // This will termiate the thread. if (bytes == 0) return; // Get the URL for the connection. The client browser sends a GET command // followed by a space,then the URL,then and identifer for the HTTP version. // Extract the URL as the string betweeen the spaces. int index1 = strFromClient.IndexOf (' '); int index2 = strFromClient.IndexOf (' ',index1 + 1); string strClientConnection = strFromClient.Substring (index1 + 1,index2 - index1); if ((index1 < 0) || (index2 < 0)) { throw (new IOException ()); } // Write a messsage that we are connecting. Console.WriteLine ("Connecting to Site " + strClientConnection); Console.WriteLine ("Connection from " + m_sockClient.RemoteEndPoint); // Create a WebRequest object. WebRequest req = (WebRequest) WebRequest.Create (strClientConnection); // Get the response from the Web site. WebResponse response = req.GetResponse (); int BytesRead = 0; Byte [] Buffer = new Byte[32]; int BytesSent = 0; // Create a response stream object. Stream ResponseStream = response.GetResponseStream(); // Read the response into a buffer. BytesRead = ResponseStream.Read(Buffer,32); StringBuilder strResponse = new StringBuilder(""); while (BytesRead != 0) { // Pass the response back to the client strResponse.Append(Encoding.ASCII.GetString(Buffer,BytesRead)); m_sockClient.Send(Buffer,BytesRead,0); BytesSent += BytesRead; // Read the next part of the response BytesRead = ResponseStream.Read(Buffer,32); } } catch (FileNotFoundException e) { SendErrorPage (404,"File Not Found",e.Message); } catch (IOException e) { SendErrorPage (503,"Service not available",e.Message); } catch (Exception e) { SendErrorPage (404,e.Message); Console.WriteLine (e.StackTrace); Console.WriteLine (e.Message); } finally { // disconnect and close the socket. if (m_sockClient != null) { if (m_sockClient.Connected) { m_sockClient.Close (); } } } // Returning from this method will terminate the thread. } // Write an error response to the client. void SendErrorPage (int status,string strReason,string strText) { SendMessage (m_sockClient,"HTTP/1.0" + " " + status + " " + strReason + "\r\n"); SendMessage (m_sockClient,"Content-Type: text/plain" + "\r\n"); SendMessage (m_sockClient,"Proxy-Connection: close" + "\r\n"); SendMessage (m_sockClient,"\r\n"); SendMessage (m_sockClient,status + " " + strReason); SendMessage (m_sockClient,strText); } // Send a string to a socket. void SendMessage (Socket sock,string strMessage) { buffer = new Byte [strMessage.Length + 1]; int len = ASCII.GetBytes (strMessage.tochararray(),strMessage.Length,buffer,0); sock.Send (buffer,len,0); } // Read a string from a socket. int ReadMessage (Socket sock,byte [] buf,ref string strMessage) { int iBytes = sock.Receive (buf,1024,0); strMessage = Encoding.ASCII.GetString (buf); return (iBytes); } } }
希望本文所述对大家的C#程序设计有所帮助。
CshBBrain V2.0.0 版发布,WebSocket服务器
开源WebSocket服务器CshBBrain V2.0.0版本发布。在V2.0.0版本中添加服务器集群功能,以满足大并发量高容量的分布式系统开发。如果你需要开发带有集群功能的WebSocket服务器,CshBBrain V2.0.0也许是非常适合你的选择。在CshBBrain V2.0.0中你可以将某个服务器设置为纯粹的集群管理服务器,或纯粹的业务节点服务器和集群管理业务节点服务器3中类型。
管理服务器启动日志:
13:16:34,008 INFO MasterServer:464 - 数据读取回写监听线程创建成功:请求数据传输监听线程0
13:16:34,008 INFO MasterServer:803 - 请求处理调度线程创建完毕
13:16:34,024 INFO MasterServer:464 - 数据读取回写监听线程创建成功:请求数据传输监听线程1
13:16:34,024 INFO MasterServer:803 - 请求处理调度线程创建完毕
13:16:34,024 INFO MasterServer:929 - 连接监听线程创建成功
13:16:34,024 INFO MasterServer:960 - 集群连接监听线程创建成功
13:16:34,039 INFO MasterServer:992 - 集群服务器准备就绪,等待集群请求到来
13:16:34,039 INFO MasterServer:1055 - 服务器准备就绪,等待请求到来
13:16:57,226 INFO ClustersDecoder:99 - the msg received:
CshBBrain
Host:192.168.1.111
Key:789a71bbd02e47b8a45c7810
Protocol:Protocol
13:16:57,226 INFO ClustersDecoder:224 - 789a71bbd02e47b8a45c7810258EAFA5-E914-47DA-95CA-C5AB0DC85B11
13:16:57,257 INFO ClustersDecoder:340 - the response: CshBBrain
Host:192.168.1.111
Accept:fdW9PLg7Nj/qsdmwx+FXLL/k/9w=
Protocol:protocol
13:16:57,335 INFO Response:158 - 向客户端传输数据的长度 : 87
业务节点服务器启动日志:
13:16:57,054 INFO MasterServer:464 - 数据读取回写监听线程创建成功:请求数据传输监听线程0
13:16:57,070 INFO MasterServer:803 - 请求处理调度线程创建完毕
13:16:57,070 INFO MasterServer:464 - 数据读取回写监听线程创建成功:请求数据传输监听线程1
13:16:57,070 INFO MasterServer:803 - 请求处理调度线程创建完毕
13:16:57,070 INFO MasterServer:929 - 连接监听线程创建成功
13:16:57,070 INFO MasterServer:960 - 集群连接监听线程创建成功
13:16:57,085 INFO MasterServer:258 - 集群通信客户端消息处理线程创建完毕
13:16:57,085 INFO MasterServer:313 - 成功连接到集群服务器 192.168.1.220 的端口:9191
13:16:57,101 INFO MasterServer:1055 - 服务器准备就绪,等待请求到来
13:16:57,116 INFO MasterServer:992 - 集群服务器准备就绪,等待集群请求到来
13:16:57,148 INFO Client:668 - CshBBrain
Host:192.168.1.111
Key:789a71bbd02e47b8a45c7810
Protocol:Protocol
13:16:57,148 INFO ClustersCoder:162 - the response: CshBBrain
Host:192.168.1.111
Key:789a71bbd02e47b8a45c7810
Protocol:Protocol
13:16:57,226 INFO Response:158 - 向客户端传输数据的长度 : 80
13:16:57,335 INFO ClustersDecoder:99 - the msg received:
CshBBrain
Host:192.168.1.111
Accept:fdW9PLg7Nj/qsdmwx+FXLL/k/9w=
Protocol:protocol
CshBBrain V2.0.1 发布,WebSocket服务器
CshBBrain V2.0.1:
完善服务器集群管理控制功能,持续优化架构让服务器以最大的并行度运行。
1.完成服务器集群中的:集群节点服务器系统参数收集统计,集群管理服务器控制集群节点服务器增加 读写监听线程数量 和工作线程数量,管理服务器给客户端分派节点服务器等功能。
2.将处理结果转换为buffer中的字节的工作放到工作线程中来完成,以达到最大程度的并行运行。
3.集群管理功能的用户界面与交互功能将将在接下来的一个小版本中提供,敬请关注。
4.最新代码和下载包已经发布到googlecode和github上。
googlecode:http://code.google.com/p/cshbbrain/downloads/list
github:https://github.com/CshBBrain/CshBBrain/downloads
当然你也可以直接用svn或github获取最新的源代码。
感谢您的关注!CshBBrain V4.0将支持Java AIO技术。
使用config_1.properties 的配置内容启动集群管理服务器,启动成功后在后台将看到如下信息,表示集群管理服务器启动成功:
09:00:09,156 INFO MasterServer:542 - 数据读取回写监听线程创建成功:请求数据传输监听线程0
09:00:09,171 INFO MasterServer:937 - 请求处理调度线程创建完毕
09:00:09,187 INFO MasterServer:542 - 数据读取回写监听线程创建成功:请求数据传输监听线程1
09:00:09,187 INFO MasterServer:937 - 请求处理调度线程创建完毕
09:00:09,218 INFO MasterServer:1063 - 连接监听线程创建成功
09:00:09,250 INFO MasterServer:1189 - 服务器准备就绪,等待请求到来
09:00:09,265 INFO MasterServer:1094 - 集群连接监听线程创建成功
09:00:09,265 INFO MasterServer:1126 - 集群服务器准备就绪,等待集群请求到来
使用config_2.properties 的配置内容启动集群节点服务器,启动成功后在后台将看到如下信息,表示集群节点服务器启动成功:
21:12:26,921 INFO Client:718 - CshBBrain
Host:192.168.1.220
Key:2d899c066a764141a4111986
Protocol:Protocol
节点服务器向管理服务器发起握手请求并获取到管理服务器的响应:
握手请求:
21:12:26,921 INFO ClustersCoder:163 - the response: CshBBrain
Host:192.168.1.220
Key:2d899c066a764141a4111986
Protocol:Protocol
21:12:27,140 INFO Response:128 - the postion of the data in write: 80
21:12:27,140 INFO Response:135 - translate size:80
21:12:27,140 INFO Response:160 - 向客户端传输数据的长度 : 80
握手响应:
21:12:27,359 INFO ClustersDecoder:99 - the msg received:
CshBBrain
Host:192.168.1.220
Accept:EwTk4R9Kre88pM4vMmCMQcSA59w=
Protocol:protocol
21:12:27,359 INFO ClustersDecoder:226 - 2d899c066a764141a4111986258EAFA5-E914-47DA-95CA-C5AB0DC85B11
管理服务器收到握手请求并进行握手处理返回握手处理结果给节点服务器,下面是管理服务器的后台输出:
21:12:27,156 INFO ClustersDecoder:99 - the msg received:
CshBBrain
Host:192.168.1.220
Key:2d899c066a764141a4111986
Protocol:Protocol
21:12:27,187 INFO ClustersDecoder:226 - 2d899c066a764141a4111986258EAFA5-E914-47DA-95CA-C5AB0DC85B11
21:12:27,203 INFO ClustersDecoder:342 - the response: CshBBrain
Host:192.168.1.220
Accept:EwTk4R9Kre88pM4vMmCMQcSA59w=
Protocol:protocol
握手成功后,节点服务器向管理服务器汇报配置参数,管理服务器收到信息后会返回“action=1000”响应,下面是节点服务器的后台输出信息:
21:13:23,281 INFO MasterServer:377 - 节点服务器:192.168.1.220:3865
服务器CPU内核数量:2
服务器读写监听线程数量:2
服务器工作线程数量:10
活跃连接客户端数量:0
活跃集群连接客户端数量:0
活跃本地连接客户端数量:0
21:13:23,312 INFO Response:314 - the postion of the data: 2
21:13:23,312 INFO Response:314 - the postion of the data: 110
21:13:23,312 INFO Client:718 - action=1&coreCount=2&readerWriterCount=2&workerCount=10&clientCount=0&clustersCount=0&port=7070&localCount=0
21:13:23,312 INFO Response:128 - the postion of the data in write: 110
21:13:23,312 INFO Response:135 - translate size:110
21:13:23,312 INFO Response:160 - 向客户端传输数据的长度 : 110
21:13:23,359 INFO ClustersDecoder:196 - jason,the msg is : action=1000
我们今天的关于RabbIT 4.9 发布,Web代理服务器和web代理服务器软件的分享就到这里,谢谢您的阅读,如果想了解更多关于ASP.NET Core 实现带认证功能的Web代理服务器、C#实现多线程的Web代理服务器实例、CshBBrain V2.0.0 版发布,WebSocket服务器、CshBBrain V2.0.1 发布,WebSocket服务器的相关信息,可以在本站进行搜索。
本文标签: