在日常的开发中我们经常会遇到这样的小问题,我想把来自某个特定URL的请求(流量)重定向某一个脚本,这个脚本可能有一下特性:速度极快,用来处理一些高并发请求
比如lua,当然这个需要openresty支持,具体配置可以查看openresty的手册,下面是具体的配置//直接返回静态数据
location = /api/router {
default_type text/html;
return 200 '{"code":"1","reason":"lua success"}';
}//将请求转发给lua脚本
location = /notice/api/router {
default_type text/html;
content_by_lua_file /home/wwwroot/abc/boost.lua;
}使用脚本语言简单特性,测试某些特殊功能
比如我需要使用php解析http请求,使用原生开发来调试程序//精确匹配,将请求转给php脚本
location =/notice {
try_files $uri $uri/ /aa.php;
}将部分业务解耦
将一些特殊业务单独规划出来,不纳入同意的路由管理中
凡此种种