Practical development Nginx Module
简体中文
echo string
Nginx1.0.10 https://github.com/nginx/nginx/releases/tag/release-1.0.10
The development environment configuration
OS : CentOS Linux release 7.2.1511 (Core)
Install a clean compile Nginx
Download a Nginx10.10 and unpack it
Install the GCC and the lib Nginx need
./configure --prefix=/usr/local/nginx && make && make install
Nginx run
Definition module configuration structure
typedef struct {
ngx_str_t ed ; //该结构体定义在这里 https://github.com/nginx/nginx/blob/master/src/core/ngx_string.h
} ngx_http_echo_loc_conf_t ;
Define Nginx instruction and parameter conversion function
definition module Context
Define the type of ngx_http_module_t structure variables
Initialize a configuration structure
Will the father block configuration information incorporated into this structure Implement the configuration of inheritance
Write the Handler really work part of the module
Finishing module code According to the Nginx official specification
ngx_addon_name=ngx_http_echo_module
HTTP_MODULES=" $HTTP_MODULES ngx_http_echo_module"
NGX_ADDON_SRCS=" $NGX_ADDON_SRCS $ngx_addon_dir /src/ngx_http_echo_module.c"
./configure --prefix=/usr/local/nginx/ --add-module=/root/ngx_dev && make && make install
Modify the Nginx configuration file test Module
Nginx echo Module The successful running
If the repo help you welcome star fork Thanks!
http://wiki.nginx.org/Configuration
http://tengine.taobao.org/book/
http://blog.codinglabs.org/articles/intro-of-nginx-module-development.html
https://www.nginx.com/resources/wiki/modules/