nginx需安装lua模块,可使用集成环境OpenResty。OpenResty开源框架,它是一款基于 NGINX 和 LuaJIT 的 Web 平台。
linux安装参考
http://openresty.org/cn/getting-started.html
location /aa {
access_by_lua '
local args = ngx.req.get_headers();
local token1 = args["appid"];
local token2 = math.floor(ngx.time()/100);
local errs = token2 .. "oh,Only Authorized Request will be Processe"
if not token1 then
ngx.status = ngx.HTTP_FORBIDDEN
ngx.say(errs)
ngx.exit(200)
end
if ( ( token1+0 == token2 ))then
return
end
if ( ( token1+0 == token2-1 ))then
return
end
if ( ( token1+0 == token2+1 ))then
return
end
ngx.status = ngx.HTTP_FORBIDDEN
ngx.say(errs)
ngx.exit(200)
';
proxy_pass http://127.0.0.1:180/;
}