#phases
Posts
-
Digging into nginx's Source 9: The 11 Phases and Finding the location — In What Order a Request Is Handled
Once its headers are read, a request walks through 11 phases inside nginx. We check in the source how the handlers that modules register are flattened at config time into a single ph[] array, and how ngx_http_core_run_phases() drives that array through checker functions. We also see how location blocks become a prefix tree and are chosen in the order =, ^~, regex and 1.31.x's predicate locations, and which slot of the array rewrite last/break, internal redirects and named locations go back to — with debug logs and gdb.