Nginx source code analysis: core module analysis and common problems
Guide: Many architects want to understand and master high-performance server development. One way to do this is to read the good source code, where nginx is an industry-renowned implementation of a high-performance web server. How to effectively read and understand nginx? This article introduces core modules such as HTTP and common problems in reading nginx source code, helping everyone to better read and understand the implementation of nginx key modules. Chen Ke, with ten years of experience in the industry, has worked as a development engineer & architect in Zhejiang Telecom, Alibaba, Huawei, and Wuba Tongcheng. He is currently responsible for the back-end architecture and operation and maintenance of Helijia. Blog address: http://www.dumpcache.com/wiki/doku.php After Nginx parses the request line and request header, it defines a total of eleven stages, which are introduced as follows How the HTTP module works Eleven phase definitions of HTTP processing typedef enum { NGX_HTTP_POST_READ_PHASE = 0, // Read request content phase NGX_HTTP_SERVER_REWRITE_PHASE, // Server request address rewriting phase NGX_HTTP_FIND_CONFIG_PHASE, // Configuration lookup phase NGX_HTTP_REWRITE_PHASE, // Location request address rewriting phase NGX_HTTP_POST_REWRITE_PHASE, // request address rewrite submission phase NGX_HTTP_PREACCESS_PHASE, // access permission check preparation…