ProxyMachie是一个简单的7层TCP路由代理,基于EvetMachie构建,可使用Ruby语言配置路由规则。如果你需要将不同的请求内容转发到后端不同的服务器上,那么ProxyMachie非常适合你。
ProxyMachie主要为Github的集群架构而开发,每天可代理几百万请求,性能和内存占用表现良好。
安装:
$ gem istall proxymachie -s https://gemcutter.org使用方法:
Usage: proxymachie -c <cofig file> [-h <host>] [-p <port>]Optios: -c, --cofig CONFIG Cofiguratio file -h, --host HOST Hostame to bid. Default 0.0.0.0 -p, --port PORT Port to liste o. Default 5432示例配置:
class GitRouter # Look at the routig table ad retur the correct address for +ame+ # Returs "<host>:<port>" e.g. "ae8f31c.example.com:9418" def self.lookup(ame) ... eded# Perform cotet-aware routig based o the stream data. Here, the# header iformatio from the Git protocol is parsed to fid the # userame ad a lookup routie is ru o the ame to fid the correct# backed server. If o match ca be made yet, do othig with the# coectio.proxy do |data| if data =~ %r{^....git-upload-pack /([\w\.\-]+)/[\w\.\-]+\000host=\w+\000} ame = $1 { :remote => GitRouter.lookup(ame) } else { :oop => true } eded









评论