nginx has wide range of debugging features, including detailed debug log. Note that most most debugging nits are only activated when nginx compiled with --with-debug configure argument.
See A debugging log in documentation for details.
To activate debugging log you have to compile nginx with --with-debug configure option and set debug level in error_log directive.
It's possible to debug only connections from specified addresses via debug_connection directive.
worker_rlimit_core 500M; working_directory /path/to/cores/; to nginx.conf is enough. Then run gdb to obtain backtrace as usual, e.g.
gdb /path/to/nginx /path/to/cores/nginx.core bt backtrace full If your gdb backtrace warns that No symbol table info available. then you will need to recompile Nginx with the appropriate compiler flags for debugging symbols.
CFLAGS="-g -O0" ./configure ....
debug_points abort; to nginx.conf and configure core dumps (see above). This will result in abort() call once nginx detects leak and core dump.
set $c = &ngx_cycle->connections p $c->log->connection p *$c set $r = (ngx_http_request_t *) $c->data p *$r In particular, "p $c->log->connection" will print connection number as used in logs. It will be possible to grep debug log for relevant lines, e.g.
fgrep ' *12345678 ' /path/to/error_log;
Asking for help
When asking for help with debugging please provide:
nginx -V output full config debug log backtrace (if nginx exits on signal)
A debugging log