nginx中编写lua拦截器

先配置nginx
        location ~ .*\.(php|php5)?$
        {
                if ($request_uri ~ "one/test") {
                        access_by_lua_file /opt/nginxrw/lua/limiturl.lua;
                }
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi.conf;
        }

然后就编写相应的lua脚本就可以了
要注意如果有特殊字符,则要加转义,如要拦截地址:firstsale/AjaxPanicNow
则要如下写
if ($request_uri ~ "firstsale\/AjaxPanicNow") {
                        rewrite_by_lua_file /opt/nginxrw/lua/limiturl.lua;
                }

转载于:https://www.cnblogs.com/szprg/p/4588732.html

你可能感兴趣的:(nginx中编写lua拦截器)