You should always check out Nginx's error log file (specified by the
error_log directive in
nginx.conf) for any errors or warnings.
If you prefer redirecting common Lua errors to the HTTP response body during Lua development, you can put a Lua pcall call on the top level of your Lua code to catch and redirect any Lua exceptions. But keep in mind, not all errors can be captured this way because you could have errors when sending out the response, then it is impossible to put such errors into the response body.
You can find additional tools in the stap++ project:
These tools can not only debug functional problems, but also profile online servers to find performance bottlenecks.