ngx.exit and custom body
Hi I am using the latest offical openresty. I'm building a redis+lua+openresty environment,which the configuration is:
server {
...
error_page 404 /404.html;
location / {
content_by_lua_block {
local redis = require "resty.redis"
local red = redis:new()
local ok,err = red:connect("127.0.01",6379)
if not ok then
ngx.say("failed to connect: ",err)
return
end
local res,err = red:hget("mykey","mytestfield")
if not res then
ngx.say("failed to get data: ",err)
return
end
if res == ngx.null then
ngx.status = 404
return ngx.exit(ngx.HTTP_NOT_FOUND)
end
ngx.say(res)
}
}
}
when found no data in redis,it return ngx.exit(ngx.HTTP_NOF_FOUND).I want it to return handler to nginx to process status 404 using error_page directive.How can I do that?
error_page as well as content_by_lua_block are content handlers. You might wanna change to access_by_lua_block. Nevertheless such questions usually belong to the mailing list: https://groups.google.com/forum/#!forum/openresty-en
Is this issue resolve .I tried both content and access by lua block to return ngx.exit(503) which is having error_page directive. But browser is still showing default 503 page.