Posted on and Updated on

HTTP request processing phases in Nginx

Nginx processes HTTP requests in multiple phases. In each of the phases there might be 0 or more handlers called. In the Nginx source code phases have specific constants associated with them. Here is a list of all phases:

  1. NGX_HTTP_SERVER_REWRITE_PHASE — the phase of request URI transformation on virtual server level;
  2. NGX_HTTP_FIND_CONFIG_PHASE — the phase of configuration location lookup;
  3. NGX_HTTP_REWRITE_PHASE — the phase of request URI transformation on location level;
  4. NGX_HTTP_POST_REWRITE_PHASE — request URI transformation post-processing phase;
  5. NGX_HTTP_PREACCESS_PHASE — access restrictions check preprocessing phase;
  6. NGX_HTTP_ACCESS_PHASE — access restrictions check phase;
  7. NGX_HTTP_POST_ACCESS_PHASE — access restrictions check post-processing phase;
  8. NGX_HTTP_TRY_FILES_PHASE — try_files directive processing phase;
  9. NGX_HTTP_CONTENT_PHASE — content generation phase;
  10. NGX_HTTP_LOG_PHASE — logging phase.

On every phase you can register any number of your handlers. Continue reading “HTTP request processing phases in Nginx”