Nginx USES the Lua script to configure the example

  • 2020-05-09 19:53:06
  • OfStack

First configuration 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;
        }

Then just write the lua script
Note that if there are special characters, escape them, such as to intercept the address: firstsale/AjaxPanicNow
Write it as follows

if ($request_uri ~ "firstsale\/AjaxPanicNow") {
                        rewrite_by_lua_file /opt/nginxrw/lua/limiturl.lua;
                }


Related articles: