local function nested_e() if true then ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR) else return "FOO" end end local r = nested_e() ngx.say("OK") -- ➤ curl test.localhost:8088/api/ngx/test/nested_exit