"Test Module Development" for nginx module development"

Source: Internet
Author: User

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.