Hello I have openresty nginx version 1.11.2.4.
In my nginx.conf file I have (following is an excerpt only):
http {
server{
location /test {
root /x/y/z;
content_by_lua_file /path/to/contentbylua/file;
}
}
}
The file being referenced by the content_by_lua_fle directive is:
local redis = require "resty.redis"
local red = redis:new()
red:set_timeout(1000) -- 1 sec
-- or connect to a unix domain socket file listened
-- by a redis server:
-- local ok, err = red:connect("unix:/path/to/redis.sock")
local ok, err = red:connect("127.0.0.1", 6379)
if not ok then
ngx.say("failed to connect: ", err)
return
end
ok, err = red:set("dog", "an animal")
if not ok then
ngx.say("failed to set dog: ", err)
return
end
ngx.say("set result: ", ok)
local res, err = red:get("dog")
if not res then
ngx.say("failed to get dog: ", err)
return
end
if res == ngx.null then
ngx.say("dog not found.")
return
end
I am getting the following error:
lua entry thread aborted: runtime error: /path/to/contentbylua/file: attempt to call method 'connect' (a nil value)
What am I missing? Thank you