您的位置:首页 > 运维架构 > Nginx

nginx lua 开发笔记

2016-04-18 15:39 399 查看

获取 在lua代码中获取 location 正则的参数对应的变量

// location
location ~/lua_http_2/(\w*.+) {  }

// lua
local vars=ngx.var; // 数组中存的是 location 参数值
local url="/zhuanfa/"..vars[1];

local resp = ngx.location.capture(url, {
method = ngx.HTTP_GET,
body = body,
args = {q="info.php"}
})
if resp.body then
ngx.say(resp.body);
end

网页显示输出

default_type 'text/html'; 表示在网页中输出 html ;如果没有 程序执行会下载文件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: