Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Introduction to the Nginx handler module


May 23, 2021 Nginx Getting started


Table of contents


Introduction to the handler module

I believe that after reading the module overview in the previous chapter, you have a basic understanding of the module of Nginx. B asically, the three types of modules that are most likely to be developed as third-party developers are handler, filter, and load-balancer. A Handler module is a module that accepts requests from the client and produces output. Some places say that the upstream module is actually a handler module, except that it produces content from the back-end server, not from the machine.

As mentioned in the last chapter, the content handler module can be configured in a configuration file using the location instruction, and when the Nginx system starts, each handler module has a chance to associate itself with the corresponding location. I f more than one handler module is associated with the same location, only one handler module actually works. Of course, in most cases, module developers avoid this.

Handler modules typically handle results in three situations: successful processing, processing failure (an error occurred at the time of processing), or rejection to process. I n the case of rejection processing, the processing of this location is handled by the default handler module. For example, when a static file is requested, if a handler module associated with the location refuses to process, it is processed by the default ngx_http_static_module module, which is a typical handler module.

This chapter focuses on how to write a handler module, before you study handler module writing to understand some of the basic data structure of the module.