基于nginx,使用redis存储标志.python
实现waf防火墙相似功能nginx
location /uri {git
access_by_lua_block {github
if ngx.var.path then redis
ngx.say('filter')shell
ngx.exit(ngx.HTTP_OK)cookie
endlua
}rest
proxy_pass http://10.10.10.1/python;blog
}
能够针对access_by_lua_file写很长的业务逻辑,
1) 白名单,黑名单
2) 用户cookie
3) 用户ip
均可以实现这些规则,将标记量存放到redis里面.
针对proxy_pass功能的业务是能够使用这种方式来实现的.
已经有人基于waf这种方式来控制请求参数,是否非法.
能够查看loveshell牛逼waf的项目: https://github.com/loveshell/ngx_lua_waf
lua的github项目地址超级牛逼的
https://github.com/openresty/lua-nginx-module
https://blog.cloudflare.com/cloudflares-new-waf-compiling-to-lua/