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