From caa8073c5380995d665a12fa17bc08d8471bfed6 Mon Sep 17 00:00:00 2001 From: yourpleasure Date: Thu, 8 Sep 2016 19:07:30 +0800 Subject: [PATCH 1/2] build ngx kafka module as dynamic module --- README.md | 16 ++++++++++++++++ config | 15 +++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 98fb348..830a1eb 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,16 @@ Compile this module into nginx sudo make install # or, use `sudo make upgrade` instead of `sudo make install` +In newer version of nginx(>=1.9.11), you can make this module as an dynamic module. + + git clone https://github.com/brg-liuwei/ngx_kafka_module + + # cd /path/to/nginx + ./configure --add-dynamic-module=/path/to/ngx_kafka_module + + make modules + # This will generate a objs/ngx_http_kafka_module.so in your /path/to/ngx_kafka_module and you can copy the so file to a proper location. + [Back to TOC](#table-of-contents) Nginx Configuration @@ -75,6 +85,12 @@ Add the code to nginx conf file as follows } } +If you compile module as a dynamic module, you must add + + load_module /path/to/ngx_http_kafka_module.so; + +before "http" directive besides adding the code to nginx config file. After that you can use the module by just executing `nginx -c /path/to/nginx.conf -s reload`. + [Back to TOC](#table-of-contents) diff --git a/config b/config index 46ff166..0c98a09 100644 --- a/config +++ b/config @@ -1,5 +1,12 @@ ngx_addon_name=ngx_http_kafka_module -HTTP_MODULES="$HTTP_MODULES ngx_http_kafka_module" -NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_kafka_module.c" - -CORE_LIBS="$CORE_LIBS -lrdkafka -lz -lpthread" +if test -n "$ngx_module_link"; then + ngx_module_type=HTTP + ngx_module_name=$ngx_addon_name + ngx_module_srcs="$ngx_addon_dir/ngx_http_kafka_module.c" + ngx_module_libs="-lrdkafka -lz -lpthread" + . auto/module +else + HTTP_MODULES="$HTTP_MODULES ngx_http_kafka_module" + NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_kafka_module.c" + CORE_LIBS="$CORE_LIBS -lrdkafka -lz -lpthread" +fi From 89c0119c470c72cb74437117cc389152d62ed12e Mon Sep 17 00:00:00 2001 From: yourpleasure Date: Mon, 12 Sep 2016 14:06:46 +0800 Subject: [PATCH 2/2] fix README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 830a1eb..d19cb13 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ If you compile module as a dynamic module, you must add load_module /path/to/ngx_http_kafka_module.so; -before "http" directive besides adding the code to nginx config file. After that you can use the module by just executing `nginx -c /path/to/nginx.conf -s reload`. +at the beginning of the nginx config file besides adding the code. After that you can use the module by just executing `nginx -c /path/to/nginx.conf -s reload`. [Back to TOC](#table-of-contents)