nginx lua 开发笔记

获取 在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 ;如果没有 程序执行会下载文件
原文地址:https://www.cnblogs.com/freefei/p/5404719.html