openresty 几个插件使用
1. jwt
opm get SkyLothar/lua-resty-jwt
2. cookie
opm get p0pr0ck5/lua-resty-cookie
3. http
opm get agentzh/lua-resty-http
4. template
bungle/lua-resty-template
5. 一个简单例子
集合jwt cookie 可以做安全认证处理,以及动态token 生成
jwt、cookie
location / {
access_by_lua_block {
local ck = require("resty.cookie");
local cookie, err = ck:new();
local jwt = require "resty.jwt"
local jwt_token = jwt:sign(
"lua-resty-jwt",
{
header={typ="JWT", alg="HS256"},
payload={foo="bar"}
}
)
-- ngx.say(ngx.header)
ngx.header.token_name = "dalong demo app";
cookie:set({key= "dalongapp",value = jwt_token})
}
proxy_pass http://XXXXXXXX;
}