Lightweight HTTP Server Nginx: module and Working principle

Source: Internet
Author: User
Keywords Nginx working principle HTTP Server
Tags .mall .url basic basic module block client configuration configured

Wind Network (ithov.com) original article: Nginx by the kernel and modules, in which the design of the kernel is very small and concise, the completion of the work is very simple, only through the lookup configuration file to map client requests to a location Block (location is an instruction in the Nginx configuration for URL matching), and each instruction configured in this location will start a different module to do the work accordingly.

The Nginx modules are divided into core modules, basic modules and Third-party modules, HTTP modules, event modules and mail modules are core modules, HTTP access modules, HTTP fastcgi modules, HTTP proxy modules, and HTTP The rewrite module belongs to the base module, while the HTTP upstream Request hash module, notice module, and HTTP Access key module are third-party modules, and the modules that users develop according to their needs belong to third party modules. It is with so many modules of support, Nginx function will be so powerful.

&http://www.aliyun.com/zixun/aggregation/37954.html ">NBSP; The Nginx modules are divided into three functional categories.

Port handlers (processor module). Such modules directly handle requests, and output content and modify headers information operations. Handlers processor modules generally can only have one.
Port filters (filter module). This kind of module mainly to the other processor module output meat volume modification operation, finally by Nginx output.
Port proxies (proxy class module). Such modules are nginx HTTP upstream modules, which interact with some of the backend services such as fastcgi, to achieve Service Broker and load balancing functions.

Figure I-i shows the process of Nginx module general HTTP requests and responses.

Figure 1-1 HTTP request and response process for Nginx modules

In the way of work, Nginx is divided into two modes: single work process and multiple worker process. In single worker process mode, there is a worker process in addition to the main process, the worker process is single-threaded, and in multiple worker process mode, each worker process contains multiple threads. Nginx default to single worker process mode.

Nginx modules are compiled directly into the Nginx and therefore belong to the static compilation method. After starting the Nginx, the Nginx module is automatically loaded, unlike Apache, which first compiles the module to a so file and then specifies whether to load it in the configuration file. When parsing a configuration file, each module of Nginx is likely to process a request, but the same processing request can only be completed by one module.

Related Article

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.