美文网首页
nginx拦截url关键字

nginx拦截url关键字

作者: helloweiwei | 来源:发表于2017-08-25 17:19 被阅读0次

nginx负责转发请求时,有时候需要中存在的关键字的请求,如

url : http://192.168.1.10:90/hmset/2_9f89c84a559f573636a47ff8daed0d33

2_9f89c84a559f573636a47ff8daed0d33作为url中的动态参数拼接部分

$request_uri 获取请求url。

nginx 配置应如下

location /hmget {

if ($request_uri ~* "/2_9f89c84a559f573636a47ff8daed0d33") {

return 200 "error";

}

default_type 'text/plain';

content_by_lua_file /opt/openresty/lua/hmget.lua;

}

200为返回的状态,根据需求可以返回402,404等http状态码

error为后面跟着的描述信息,也可以是其他。

相关文章

网友评论

      本文标题:nginx拦截url关键字

      本文链接:https://www.haomeiwen.com/subject/kqfpdxtx.html