Get the App
SLTechnology News&Howtos  ›  Servers  › 

How Nginx compiles connections

Shulou Source: shulou.com Published: 2022-05-31 21:28:42 10月28日 Update

This article will explain in detail how to compile links in Nginx. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Nginx organization process

/ auto/configure (get the configuration of configure and generate Makefile)

Objs/Makefile (generated by the first step)

Make (* .o generated, connected as nginx)

Demonstrate the connection process of http geo module

1.configure

Path:auto/configure

. Auto/options...2.options parameter

Path: auto/option

Path: auto/modules

Whether a configuration is enabled or not

-without-stream_geo_module disable ngx_stream_geo_module-with-debug enable debug logging

The HTTP_GEO variable is set to YES and the geo module is turned on.

If [$HTTP_GEO = YES]; then have=NGX_HTTP_X_FORWARDED_FOR. Auto/have ngx_module_name=ngx_http_geo_module ngx_module_incs= ngx_module_deps= ngx_module_srcs=src/http/modules/ngx_http_geo_module.c ngx_module_libs= ngx_module_link=$HTTP_GEO. Auto/module fi3.objs/ngx_modules.c

Extern declares the target module (geo, custom module)

Ngx_modules: registration module

Ngx_module_names: define the module name

4.objs/Makefile

Compile target .o

Connect target .o to nginx

Generation of eg:ngx_http_geo_module.o module

Objs/src/http/modules/ngx_http_geo_module.o: $(CORE_DEPS) $(HTTP_DEPS)\ src/http/modules/ngx_http_geo_module.c $(CC)-c $(CFLAGS) $(CORE_INCS) $(HTTP_INCS)\-o objs/src/http/modules/ngx_http_geo_module.o\ src / http/modules/ngx_http_geo_module.c5. Verify that the target module is connected in the nginx

Ngx_http_geo_module

Ngx_http_mytest_module (Custom Module)

➜nginx git: (hyh_test) ✗ nm objs/nginx | grep geo_mod00000001000a5420 D _ ngx_http_geo_module00000001000bdf68 b _ ngx_http_geo_module_ctx➜ nginx git: (hyh_test) ✗ ➜nginx git: (hyh_test) ✗ nm objs/nginx | grep mytest 0000000100071860 t _ ngx_http_mytest_block00000001000a5500 d _ ngx_http_mytest_commands00000001000a5570 D _ ngx_http_mytest_module00000001000bdfb8 b _ ngx_http_mytest_module_ctx➜ nginx git: (hyh_) Test) ✗ 's article on "how Nginx compiles connections" ends here. Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

Tags: Modules goals generation compilation articles more procedures configurations good practical content parameters variables articles knowledge references help related demonstration verification Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Xiaomi Huawei Apple Docker