doio-proxy
基于doio框架的快速代理,基于消息头的host实现,同时支持多路径匹配转发,不同路径可以对应不同的后台服务。
安装
npm i doio-proxy
使用
'use strict';const doio = require('doio');const doioproxy = require('doio-proxy');let hostcfg = {//会自动转换为数组的形式,默认path为 /'a.com' : 'http://localhost:8001',//会自动转换为数组的形式'b.com' : {path : '/xyz',url : 'http://localhost:8002'},//标准形式'c.com' : [{path : '/name',url : 'http://localhost:8003'},{path : '/',url : 'http://localhost:8004'}]};const app = new doio();const proxy = new doioproxy({host : hostcfg});proxy.init(app);//输出路由表app.printRoute();//监听2000端口,启用2个worker子进程处理请求app.daemon(2000, 2);