skipper 支持基于lua 的script 扩展,同时设计比较方便的filter模型,让我们可以方便
进行request、response的扩展,结合lua 社区的包我们可以快速的进行新功能的开发

环境准备

  • docker-compose 文件
    测试功能,集成了监控功能
version: "3"
services:
skipper:
#image: dalongrong/skipper:latest
build: ./
image: dalongrong/skipper-docker-build-luarocks
ports:
- "9090:9090"
- "9911:9911"
volumes:
- "./router.eskip:/router.eskip"
- "./app.lua:/app.lua"
command: skipper -enable-ratelimits -enable-prometheus-metrics -routes-file /router.eskip
g:
image: grafana/grafana
ports:
- "3000:3000"
web:
image: nginx
ports:
- "8099:80"
p:
image: prom/prometheus
volumes:
- "./prometheus.yml:/etc/prometheus/prometheus.yml"
ports:
- "9091:9090"
  • skipper dockerfile
    使用dockerfile mutilstage 进行构建,拷贝现有二进制包到一个luarocks的容器,
    同时添加了一个uuid 的模块
FROM dalongrong/skipper:latest as build

FROM abaez/luarocks:lua5.1
LABEL author="1141591465@qq.com"
WORKDIR /
COPY --from=build /usr/bin/skipper /skipper
COPY --from=build /usr/bin/eskip /eskip
ENV PATH=$PATH:/
RUN luarocks install uuid
  • uuid lua 包的使用
    app.lua
local uuid = require("uuid") --- 引用包
local json = require("json")
function request(ctx, params)
-- ctx.serve({
-- status_code=302,
-- header={
-- location="http://www.baidu.com/",
-- },
-- })
ctx.request.header["user_token"]="request_token"
end function response(ctx, params)
ctx.response.header["lua_token"]="dalongdemo";
-- local user = {
-- name="dalong",
-- age=33
-- }
local tokeninfo = {
token=uuid(), --- 使用uuid 包
status=200
}
ctx.serve({
status_code=200,
header= {
['Content-Type']="application/json",
lua_token=uuid()
},
body=json.encode(tokeninfo)
})
end
  • router 配置
hello: Path("/report/**") ->compress("text/html")-> corsOrigin()->setResponseHeader("TOKEN","dalongdemo")->responseCookie("test-session", "abc", 31536000)->
setRequestHeader("TOKEN","dalongdemo")-> "http://10.10.17.21:9000/report";
## lua 支持
app: Path("/users/**") -> lua("/app.lua", "myparam=foo", "other=bar") -> "http://www.baidu.com";
static: Path("/static/*") -> static("/static/", "/root") -> <shunt>;

运行&&测试

  • 启动
docker-compose up -d
  • 测试

说明

集成lua 模块,我们可以方便进行系统的扩展,很方便

参考资料

https://github.com/rongfengliang/skipper-prometheus-docker-compose
https://opensource.zalando.com/skipper/reference/scripts/

 
 
 
 

skipper lua 添加luarocks 包管理的更多相关文章

  1. luarocks 包管理工具

    安装方式:wget http://luarocks.org/releases/luarocks-2.2.2.tar.gz tar zxvf luarocks-2.2.2.tar.gz cd luaro ...

  2. MVC中的 程序集添加-----程序包管理器控制台

    Install-Package Microsoft.AspNet.WebApi.Owin -Version Install-Package Microsoft.Owin.Host.SystemWeb ...

  3. Lua包管理工具Luarocks详解 - 15134559390的个人空间 - 开源中国社区

    Lua包管理工具Luarocks详解 - 15134559390的个人空间 - 开源中国社区 Lua包管理工具Luarocks详解

  4. cetnos7下openresty使用luarocks 进行lua的包管理

    先安装一下包管理工具 yum install luarocks lua-devel -y luarocks install lpack ln -s /usr/lib64/lua /usr/local/ ...

  5. Openresty 学习笔记(四)lualocks包管理器安装使用

    Luarocks是一个Lua包管理器,基于Lua语言开发,提供一个命令行的方式来管理Lua包依赖.安装第三方Lua包等,社区比较流行的包管理器之一,另还有一个LuaDist,Luarocks的包数量比 ...

  6. Linux 程序包管理-YUM

    前端工具YUM管理程序包:  rpm管理软件虽然方便,但是需要手工解决软件包的依赖关系:很多时候安装一个软件需要首先安装一个或多个(有时多达上百个)其它软件,手工解决很复杂:使用yum可以解决这个问题 ...

  7. [视频教程] 包管理器方式安装使用openresty新手上路

    OpenResty是一个通过Lua扩展Nginx实现的可伸缩的Web平台,内部集成了大量精良的Lua库.第三方模块以及大多数的依赖项.用于方便地搭建能够处理超高并发.扩展性极高的动态Web应用.Web ...

  8. Xmake 和 C/C++ 包管理

    Xmake 是一个基于 Lua 的轻量级跨平台构建工具,关于 Xmake 与构建系统的介绍,我们已经在之前的文章中做了详细的介绍:C/C++ 构建系统,我用 xmake. 如果大家已经对 Xmake ...

  9. ASP.NET Core 静态文件及JS包管理器(npm, Bower)的使用

    在 ASP.NET Core 中添加静态文件 虽然ASP.NET主要大都做着后端的事情,但前端的一些静态文件也是很重要的.在ASP.NET Core中要启用静态文件,需要Microsoft.AspNe ...

随机推荐

  1. VSTO:使用C#开发Excel、Word【5】

    <Visual Studio Tools for Office: Using C# with Excel, Word, Outlook, and InfoPath >——By Eric C ...

  2. Cracking The Coding Interview 3.2

    //How would you design a stack which, in addition to push and pop, also has a function min which ret ...

  3. ASPNET MVC5 根 core

    Asp.Net Core MVC的开源地址:https://github.com/aspnet/Mvc Asp.net MVC的开源地址:http://aspnetwebstack.codeplex. ...

  4. python造数

    做性能测试时,往往需要大量的参数化数据,比如注册. from random import Random def random_str(randomlength=8): str='' chars='01 ...

  5. Java输入输出小结

    无论使用哪一种编程语言,输入输出都是我们首当其冲的,因此简单整理了 一下关于Java输入输出知识点,还有些内容摘自其它博客,忘见谅. 第一部分,让我们看一下Java的输出 public class M ...

  6. capjoint conversations with Chenweiwen

    This event is quite small for teleseismic stations, which means it will be more strongly affected by ...

  7. Java基础复习

    java语言的一个核心:jdk, java development kits---面向开发人员jre, java Runtime Environment---服务器上 java虚拟机---(以字节码为 ...

  8. web.config 冲突的解决办法 (主目录子目录分别帮定域名导至出现错误)

    IIS上在主站点下搭建虚拟目录后,子站点中的<system.web>节点与主站点的<system.web>冲突解决方法: 在主站点的<system.web>上一级添 ...

  9. Java学习笔记10(面对对象:构造方法)

    在开发中经常需要在创建初始化对象时候明确对象的属性值, 比如Person对象创建的时候就给Person的属性name,age赋值, 这里就要用到构造方法: 构造方法是类的一种特殊方法,它的特殊性体现在 ...

  10. Bug04_spring注解报错

    maven 的pom文件中, 没有导入spring的依赖 <dependency> <groupId>org.springframework</groupId> & ...