Nginx complete and compile the custom module

Source: Internet
Author: User
Keywords Nginx compiling customizing modules
Tags an application application code compile compiling custom customizing modules directory

Now, you should be prepared to look at Nginx's real module and wonder how Nginx works. See Nginx source code is necessary, choose a function and you want to do the similar module, understand it, and then imitate it, to achieve it, is not very simple.

Emiller not write an in-depth reading of the Nginx module of the article, absolutely not, this is an application-oriented article, I recorded their own insights, and write their own modules, and share with the world.

First, you need a directory to put your module, preferably not in the N Ginx code directory. You need at least two files in your directory:

· "Config"
· "Ngx_http_<your module>_module.c"

The config file is included in the./configure configuration and requires some configuration.

Filter module "config" file:

Ngx_addon_name=ngx_http_<your Module>_module

http_aux_filter_modules= "$HTTP _aux_filter_modules ngx_http_<your module>_module"

ngx_addon_srcs= "$NGX _addon_srcs $ngx _addon_dir/ngx_http_<your module>_module.c"

"Config" file for other modules:

Ngx_addon_name=ngx_http_<your Module>_module

http_modules= "$HTTP _modules ngx_http_<your module>_module"

ngx_addon_srcs= "$NGX _addon_srcs $ngx _addon_dir/ngx_http_<your module>_module.c"

As for the C source file, I suggest directly to the code similar to the module, and then renamed, Modify, to meet your requirements on it.

Now start compiling:

./configure–add-module=path/to/your/new/module/directory

Make

Make install

If you need to add a library file, just add the command to the config file:
core_libs= "$CORE _libs-lfoo"
Foo is the name of the library you want to join.

If you have any good stuff done, send it to the Nginx mailing list and share it with you.

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.