- Parsing section
- Dynamically load all modules, maintaining a global array modules[nmodules];
- Parse the configuration file, record the modules used for each block and sub-block, subdivide to the location level (merge), maintain a global array call_modulers[nlocations][ncallmodulers], whenever a location is generated, nlocations++;
- Add default module and configuration for each location in Call_modulers, all modules are loaded;
- Each location in the merge Call_modulers uses the callback of the module's phase, which can be replaced by local variables based on the order in which the modules are called, or in the order in which they are loaded.
- Process section
- Get rid of all phase processes
- According to the request and location matching rules, find the call_modulers used;
- In the original call phase place to call to find the call_modulers location of the phase;
- The global variables used in request and response processing are replaced with local variables for each location.
Nginx module Dynamic loading (HTTP)