How nginx processes a TCP/UDP session

A TCP/UDP session from a client is processed in successive steps called phases:

Post-accept
The first phase after accepting a client connection. The ngx_stream_realip_module module is invoked at this phase.
Pre-access
Preliminary check for access. The ngx_stream_limit_conn_module module is invoked at this phase.
Access
Client access limitation before actual data processing. The ngx_stream_access_module module is invoked at this phase.
SSL
TLS/SSL termination. The ngx_stream_ssl_module module is invoked at this phase.
Preread
Reading initial bytes of data into the preread buffer to allow modules such as ngx_stream_ssl_preread_module analyze the data before its processing.
Content
Mandatory phase where data is actually processed, usually proxied to upstream servers, or a specified value is returned to a client.
Log
The final phase where the result of a client session processing is recorded. The ngx_stream_log_module module is invoked at this phase.