Nginx Module Self-development One: Understanding before development

Source: Internet
Author: User

Personally feel to really understand the source code, if only stay in theory is not enough, so from now on, to start learning to develop their own nginx module, and then in turn to understand Nginx itself code.

Nginx send files or forward requests to other servers, there is processing module processing, but need to compress or add something on the server, can adopt filter module, or some core modules are mainly responsible for managing network layer and application layer of the Protocol. If the processing module reverse-proxies the request to the backend server, it becomes another class of modules: the Load Balancer module. The Load Balancer module is configured with a set of back-end servers that, when an HTTP request comes in, determines which server should receive the request. Nginx Load Balancer module By default in two ways: rotation, it handles the way the request is like a card game from beginning to end distribution; IP hashing, in the case of numerous requests, it ensures that requests from the same IP are distributed to the same back-end server.

Each filter module does not wait for the previous filter module to complete, it can use the output of the previous filter module as its processing content; a bit like a pipeline in Unix.
The filter module can operate in buffer (buffers), which are usually one page (4K) in size, but you can also configure it in the nginx.conf file. This means, for example, that the module can compress the reply from the back-end server and then reach the client like a stream until the entire reply is sent.

Functions can perform certain functions at the following times:
? Before the service reads the configuration file
? Read every configuration instruction that exists for location and server or any other part
? When Nginx initializes the configuration of the global section
? When Nginx initializes the configuration of the host part (such as host/port)
? When Nginx merges the configuration of the global part with the configuration of the host part
? When Nginx initializes the location part configuration
? When Nginx merges its upper-level host configuration with the location-part configuration
? When the Nginx primary (master) process starts
? When a new work process (worker) starts
? When a worker process exits
? When the main process exits
? Processing requests
? Filter back the head
? Filter the body of the reply
? Select a back-end server
? Initializing a request to a back-end server
? Reinitialization of requests to the backend server
? Handling replies from back-end servers
? Complete the interaction with the back-end server

Summary

The above content is the reference Emiller Nginx Module Development Guide, I think now a lot of online has deviated from the spirit of open source, some of the resources disguised with points such as to obtain, so personal decision to contribute a force, I will see the good information I have to open free for everyone to download.

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the Nginx module self-development one: Before the development of the understanding, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.