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;}
