nginx workflow

     NGINX the http request processing flow is divided into 11 stages, logical segments, module units for processing. Http each stage may comprise a plurality of modules, each stage of pipeline processing request form. Such hierarchical processing mode is similar to the 7 layer model of a computer network, each module processing request in an orthogonal manner, brings low coupling, the coupling between the module by low flexibility.

  1. NGX_HTTP_POST_READ

   Processing stage after receiving the full HTTP headers, located before rewriting URI;

  2. NGX_HTTP_SERVER_REWRITE

    URI and before the match location, modify the URL stage for redirecting, this stage is performed in the server block rewrite instruction, the location outside the block. During the reading of the request header, NGNIX find the corresponding virtual server configuration according to the host and port.

  3, NGX_HTTP_FIND_CONFIG

   URI location for a matching block in accordance with the configuration phase, which after after overwriting the URI to find the corresponding location, the stage may be performed multiple times, there may rewrite instruction-level location.

  4. NGX_HTTP_REWITR

   After finding the phase of a block location, and then modify the URI, the URI rewriting location level stage which performs location substantially rewriting instruction may also be performed multiple times.

  5. NGX_HTTP_POST_REWRITE

     In order to prevent the overwriting URI cause death cycle later stage, location rewriting level, to check if there is the URI rewrite stage, and jump to the right according to result.

  6. NGX_HTTP_PERACCESS

    Access control of the previous stage, the stage before the access controls, generally used for access control, such as restrictions on access frequency, the number of connections and the like.

  7. NGX_HTTP_ACCESS

     Access control stage, let HTTP module determines whether to allow the request to enter NGNIX server, such as permission to blacklist based control, access control based on user passwords and so on.

  8. NGX_HTTP_POST_ACCESS

     After access to the control stage, the result of execution of stages corresponding to stages of access control process, the user transmits the service error code rejected, a rejection for the respective phases.

  9. NGX_HTTP_TRY_FILES

     Is provided access to static resources, processing stage try_files instruction, if the instruction is not configured try_files, this phase is skipped.

  10. NGX_HTTP_CONTENT

     Stage process as an HTTP request, the HTTP module entering this stage most of - generating a respective content phase, which produces a corresponding, sent to the client.

  11. NGX_HTTP_LOG

   End log phase after processing the request, the access log recording stage.

 

Guess you like

Origin www.cnblogs.com/wust-hy/p/11094432.html