We have an elaborate URl rewriter written using mod_python with Apache. We rewrote it in Lua with Apache's mod_lua but the Lua integration in Apache is incomplete and we may not want to deploy this.
I'm iteratively porting it now to use ngx_lua with nginx. For readability I'm structuring the code as a "main" .lua file that uses "require" to include other code written as Lua modules. So the main routine uses
local config = require "config"
local cookie = require "cookie"
and so forth. And the modules all contain their own initial set of "requires", e.g.
local ngx = require "ngx"
local util = require "util"
etc., followed by
module(...)
So far so good, but it seems that in anything other than the "main" code file, an attempt to use "pairs" or "ipairs" to walk a table produces a run-time error like this:
2013/03/01 09:43:24 [error] 28396#0: *1566 lua entry thread aborted: runtime error: /usr/local/openresty/nginx/cookie.lua:37: attempt to call global 'pairs' (a nil value)
I know this is some sort of C binding error but I don't have a good idea about how to correct it. Can someone suggest something?
I'm running the most recent development openresty bundle (1.2.7.1), built from source using --with-luajit.
Thanks.