【openresty】lua的使用

openresty使用lua

1,content_by_lua

location /testlua {
  content_by_lua "ngx.say('hello world')";
}

输出,hello world

2,content_by_lua_block

location /testlua {
  content_by_lua_block {
       ngx.say("hello world");
  } 
}

content_by_lua_block {} 表示内部为lua块,里面可以应用lua语句

3,content_by_lua_file

location /testlua {
  content_by_lua_file /usr/local/lua/test.lua;
}

content_by_lua_file 就是引用外部lua文件

cat /usr/local/lua/test.lua
  ngx.say("hello world");

通常采用lua文件方式

发布了192 篇原创文章 · 获赞 18 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/luolinll1212/article/details/103964046