lua-nginx-module模块地址
https://github.com/openresty/lua-nginx-module
It is highly recommended to use OpenResty releases which integrate Nginx, ngx_lua, LuaJIT 2.1, as well as other powerful comp ...……
lua的module好像是5.1开始有的
在xx.lua的开头写上
module('my_module')
这行等价于如下几行
local name = 'my_module'
local M = {}
_G = M
package.loaded = M
setfenv(1, M)
但是此时setfenv后就无法访问原_G ...……
--获取客户端ip
function get_client_ip()
local headers=ngx.req.get_headers()
local ip=headers or headers or ngx.var.remote_addr or amp;quot;0.0.0.0amp;quot;
return ip
end
……
http://timothyqiu.com/archives/lua-note-table-traversal-using-c-api/
C API 遍历 Table
1 lua_getglobal(L, t);
2 int index = lua_gettop(L);
3 lua_pushnil(L);
4 while (lua_next(L, index)) {
5 ...……