ProxyMachine 7 层 TCP 路由代理开源项目

我要开发同款
匿名用户2015年02月17日
26阅读
开发技术Ruby
所属分类服务器软件、代理服务器软件
授权协议MIT

作品详情

ProxyMachine是一个简单的7层TCP路由代理,基于EventMachine构建,可使用Ruby语言配置路由规则。如果你需要将不同的请求内容转发到后端不同的服务器上,那么ProxyMachine非常适合你。

ProxyMachine主要为Github的集群架构而开发,每天可代理几百万请求,性能和内存占用表现良好。

安装:

$ gem install proxymachine -s https://gemcutter.org

使用方法:

Usage:  proxymachine -c <config file> [-h <host>] [-p <port>]Options:  -c, --config CONFIG              Configuration file  -h, --host HOST                  Hostname to bind. Default 0.0.0.0  -p, --port PORT                  Port to listen on. Default 5432

示例配置:

class GitRouter  # Look at the routing table and return the correct address for +name+  # Returns "<host>:<port>" e.g. "ae8f31c.example.com:9418"  def self.lookup(name)    ...  endend# Perform content-aware routing based on the stream data. Here, the# header information from the Git protocol is parsed to find the # username and a lookup routine is run on the name to find the correct# backend server. If no match can be made yet, do nothing with the# connection.proxy do |data|  if data =~ %r{^....git-upload-pack /([\w\.\-]+)/[\w\.\-]+\000host=\w+\000}    name = $1    { :remote => GitRouter.lookup(name) }  else    { :noop => true }  endend
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论