使用skipper 扩展fabio 的路由&&http proxy 功能
skipper 具有强大的http 路由功能,fabio 是一个方便的基于consul 的负载均衡软件,
我们可以方便的使用skipper 路由功能进行fabio的扩展,使用registrator 进行服务注册
环境准备
- docker-compose
version: "3"
services:
fabio:
image: fabiolb/fabio
ports:
- "9999:9999"
- "9998:9998"
volumes:
- "./fabio.properties:/etc/fabio/fabio.properties"
consul:
image: consul
command: agent -config-file=/usr/local/etc/consul/server_agent.json
volumes:
- "./consul.json://usr/local/etc/consul/server_agent.json"
ports:
- "8500:8500"
web:
image: nginx
ports:
- "80:80"
environment:
- SERVICE_TAGS=urlprefix-/
- SERVICE_80_CHECK_HTTP=/
- SERVICE_80_NAME=web-app
- SERVICE_CHECK_INTERVAL=10s
- SERVICE_CHECK_TIMEOUT=5s
ip:
build:
context: ./
dockerfile: Dockerfile-ip
image: dalongrong/openresty-ip
skipper2:
image: dalongrong/skipper
environment:
- SERVICE_TAGS=urlprefix-/ip
- SERVICE_9090_NAME=skipper
- SERVICE_9090_CHECK_HTTP=/
- SERVICE_CHECK_INTERVAL=10s
- SERVICE_CHECK_TIMEOUT=5s
ports:
- "9090:9090"
volumes:
- "./router.eskip:/router.eskip"
command: skipper -enable-ratelimits -enable-prometheus-metrics -routes-file /router.eskip
registor:
image: gliderlabs/registrator:latest
command: consul://consul:8500
volumes:
- "/var/run/docker.sock:/tmp/docker.sock"
- 说明
对于skipper 的扩展使用的是nginx 重写,同时注册skipper到fabio中
ip 服务的dockerfile && nginx 配置
Dockerfile-ip
FROM openresty/openresty:alpine
COPY nginx.conf usr/local/openresty/nginx/conf/
EXPOSE 80
nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
server {
listen 80;
server_name localhost;
charset utf-8;
location / {
rewrite ^/ip(.*) $1 break;
proxy_ignore_client_abort on;
client_body_buffer_size 10M;
client_max_body_size 10G;
proxy_buffers 1024 4k;
proxy_read_timeout 300;
proxy_pass http://localhost:88;
}
location /alert {
default_type text/html;
content_by_lua_block{
ngx.say([[<script>alert("error")</script>]])
}
}
location /ip2 {
default_type text/html;
content_by_lua_block{
ngx.say(ngx.var.remote_addr)
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 88;
server_name localhost;
charset utf-8;
location / {
index index.html index.htm;
}
location /alert {
default_type text/html;
content_by_lua_block{
ngx.say([[<script>alert("error")</script>]])
}
}
location /ip2 {
default_type text/html;
content_by_lua_block{
ngx.say(ngx.var.remote_addr.."from upstream")
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
- fabio 配置文件
fabio.properties
registry.consul.addr = consul:8500
- skipper router 配置
hello: Path("/ip/*")->compress("text/html")-> corsOrigin()->setResponseHeader("TOKEN","dalongdemo")->responseCookie("test-session", "abc", 31536000)->
setRequestHeader("TOKEN","dalongdemo")-> "http://ip";
root: Path("/") -> status(200) -> <shunt>;
启动&&测试
- 启动
docker-compose up -d
- consul 效果
- fabio router 注册
- 访问
http://localhost:9999 // web nginx index page
http://localhost:9999/ip/index.html skipper 后端的openresty 服务
skipper 添加的header
http://localhost:9999/ip/ip2 skipper 后端路由接口
参考资料
https://github.com/rongfengliang/fabio-with-skipper
https://gliderlabs.github.io/registrator/latest/
https://github.com/fabiolb/fabio
https://github.com/zalando/skipper
使用skipper 扩展fabio 的路由&&http proxy 功能的更多相关文章
- Sails 关闭自动路由 Automatic Routes 功能。
Sails 关闭自动路由 Automatic Routes 功能. Sails 中的路由两种:Custom Routes 和 Automatic Routes,自定义路由和自动路由.详见文档: Sai ...
- MVC小系列(二十一)【带扩展名的路由可能失效】
mvc3之后:如果路由带上扩展名,比如这样: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRout ...
- SpringCloud:扩展zuul配置路由访问
继续上次整合SpringCloud的demo进行扩展zuul:https://www.cnblogs.com/nhdlb/p/12555968.html 这里我把zuul划分出一个模块单独启动 创建 ...
- 爱上MVC系列~带扩展名的路由失效问题
回到目录 对MVC中,对URL进行重写变得非常方便,你只要设置相应的路由规则即可完成,但进行MVC3后,发现设置了以下路由,系统具体不认 routes.MapRoute( name: "De ...
- MVC 带扩展名的路由无法访问
在MVC中,路由是必不可少的,而且MVC对Url的重写非常方便,只需要在路由中配置相应的规则即可.假如我们需要给信息详情页配置路由,代码如下: routes.MapRoute( name: " ...
- 扩展XAF模型信息实现自定义功能
如何隐藏 web listview 的 编辑控制列如下图: 这列怎么让它隐藏? 感谢[少侠]XAF_杨东 提供解答!感谢XAF_小学生整理. A: 注册自定义接口IModelListViewExt ...
- MVC采用HtmlHelper扩展和Filter封装验证码的功能
最近因为有个项目除了登录还有其他很多地方需要用到验证码的功能,所以想到了采用HtmlHelper和ActionFilter封装一个验证码的功能,以便能够重复调用.封装好以后调用很方便,只需在View中 ...
- [原创] 扩展jquery-treegrid插件, 实现勾选功能和全删按钮.
新上手一个项目, 因而正好想学习下bootstrap, 所以就采用asp.net mvc + bootstrap来做. 因为需要TreeGrid的控件, 本来想用easyUI.LingerUi.DW ...
- WiFidog 广告路由可修改功能更加智能化的几点看法
海蜘蛛Tomato出了mini版,这个对很多做WiFi营销的朋友来说,是一个福音,因为可以直接从FIR302B,一台30多块钱的路由直接刷成Hi-WiFi,而且界面这么漂亮 相信很多人已经对此界面OE ...
随机推荐
- 戴尔poweredge r730服务器配置以及系统安装
第一次给服务器安装的是ubantu系统: 首先我们开机进入小型BIOS设置一下RAID,或者进入服务器管理系统,在系统的BIOS中进行RAID设置: 开机后当看到出现< Ctrl > &l ...
- Mysql高可用
一.二进制日志 二进制日志,记录所有对库的修改,如update.修改表结构等等 需要开启二进制日志的原因: 1.主从复制都是通过二进制日志进行.主库写二进制日志,传输到从库,从库replay二进制日志 ...
- SQL-30 使用子查询的方式找出属于Action分类的所有电影对应的title,description
题目描述 film表 字段 说明 film_id 电影id title 电影名称 description 电影描述信息 CREATE TABLE IF NOT EXISTS film ( film_i ...
- Xilinx FPGA复位逻辑处理小结(转)
Xilinx FPGA复位逻辑处理小结 1. 为什么要复位呢? (1)FPGA上电的时候对设计进行初始化: (2)使用一个外部管脚来实现全局复位,复位作为一个同步信号将所有存储单元设置为一个已知的状态 ...
- Centos7创建用户su登录后显示为 bash-4.1$
useradd name [root@localhost data]# su name bash-4.2$ [root@localhost ~]# cp -a /etc/skel/. /home/na ...
- angular2.0 官网架构文档
Angular 是一个用 HTML 和 JavaScript 或者一个可以编译成 JavaScript 的语言(例如 Dart 或者 TypeScript ),来构建客户端应用的框架. 该框架包括一系 ...
- YLZ开发后端外网编写
如何取得前端的值并做处理 // 调用ESB来获取Ajaxpagerespon获得审核记录 @RequestMapping(value = "/queryBydwId", metho ...
- LeetCode子集问题
给定一组不含重复元素的整数数组 nums,返回该数组所有可能的子集(子集当中不包括重复的元素) 代码如下: def subsets(nums): target=[[]] for num in nums ...
- mysql 转义字符问题
首先我们要知道,数据库都是由表构成的,当你把数据插入到其中的一个表中的时候,比如是数字呀.文字呀等等的插入的时候能正常插入,但是一旦你要插入特殊的字符,比如说插入下面这个括号里面的内容(“ABC”)到 ...
- Day3作业及默写
1.有变量量name = "aleX leNb" 完成如下操作: 移除 name 变量对应的值两边的空格,并输出处理结果 print(name.strip()) 移除 name 变 ...