I've got a dockerized openresty running on my laptop. The only customization is bringing in my custom ngnix.conf.
This block from ngix.conf:
location /receive {
content_by_lua_block {
local mysql = require "resty.mysql"
local db, err = mysql:new()
if not db then
ngx.say("failed to instantiate mysql: ", err)
return
end
db:set_timeout(1000) -- 1 sec
local ok, err, errcode, sqlstate = db:connect{
host = "mysql",
port = 3306,
database = "db",
user = "user",
password = "password"}
if not ok then
ngx.say("failed to connect: ", err, ": ", errcode, " ", sqlstate)
return
end
ngx.say("connected to mysql.")
# more code that's never reached
}
}
Note that the block is simply the example from the lua-resty-mysql github readme.
When I hit the /receive endpoint I get a return of "failed to connect: failed to connect: no resolver defined to resolve "mysql": nil nil"
Any direction on how to debug or fix this would be appreciated.