I am trying to access redis from a lua script in my nginx.conf file on my openresty nginx server. The following is the lua script, I am using the content_by_lua_file directive to refer to it.
local redis = require "resty.redis"
local red = redis:new()
local ok, err = red:connect("127.0.0.1", 6379)
if not ok then
ngx.log(ngx.ERR, "Redis connection failure: " .. err)
return
end
I get runtime error ... attempt to call method 'connect' (a nil value)
What's going on here? Thanks