Note: the main reason why a large number of instances are used in the blog post is to allow you to practice more.
This blog post mainly uses a small example to share with you the development of the nginx HTTP module:
First, define your own test module. The sub-module will be added to the ngx_modules Global Array during compilation.
Next, we will define the ngx_http_module_t interface. because we do not want to perform any operations during the http framework initialization of the test module, we do not need to implement eight callback methods of ngx_http_module_t, as shown below:
Then, the ngx_command_t array is defined and ngx_http_test is used to process the test configuration, for example:
Finally, the header file references and processing function definitions, such:
Because my module is used for testing and demonstration, and has a single function, there are only two functions. The specific implementation code of the function:
The configuration in nginx. conf is as follows:
Compilation steps:
Make
Procedure:
./Objs/nginx
Then open your browser and enter your http: // IP/test to see how your work works.
The above code has been run by the blogger himself. If you have any questions, you can leave a message. If you are also interested in nginx, try and look forward to it.