基於nginx+lua實現防火牆動態規則請求限制

基於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/

相關文章
相關標籤/搜索