泛域名解释在 web 服务代理中比较常用的功能,主要由代理服务器根据不同请求的域名来做不需同服务的转发。Bumblebee同样也支持泛域名路由解释,就是针对不同请求的域名来制定不同的转发规则。 Bumblebee 对泛域名的转发配置非常简单只需要加载 BeetleX.Bumblebee.Configuration 新版本插件在路由管理配置即可(由于组件支持标准的http1.1协议, Bumblebee 不仅可以做webapi网关,还能做网站代理)。
Bumblebee配置路由解释,只需要加载 BeetleX.Bumblebee.Configuration 插件启动后在 Routes 中配置即可.
g = new Gateway();
g.HttpOptions(
o =>
{
o.Port = 80;
o.LogToConsole = true;
o.LogLevel = BeetleX.EventArgs.LogType.Error;
});
g.Open();
g.LoadPlugin(
typeof(Bumblebee.Configuration.Management).Assembly
);
如果不想自己编写代码可以下载编译的运行包 https://github.com/IKende/Bumblebee/blob/master/bin/ 下载1.2或更高版本;运行后 访问 http://host/__system/bumblebee/
在 Routes 添加路由规则,如果转发规则需要对域名进行一个匹配那规则是 域名|路径
beetlexjs.ikende.com|.*
以上规则是配置经过 beetlexjs.ikende.com 域访问的所有请求都到这个规则里。
以上官网的路由配置规则 beetlexjs.ikende.com|.* 路由到 http://localhost:8081/ ,而其它则路由 http://localhost:8080/ 。由于服务打开了处理服务地址输出所以访问这两个域的头信息可以看到:
ikende.com
beetlexjs.ikende.com
关注公众号
https://github.com/IKende/
高性能的服务通讯框架 Beetlex(http,rpc,gateway的详细实现 )