Giter Club home page Giter Club logo

ngx_devel_kit's Introduction

Name

Nginx Development Kit (NDK)

Table of Contents

Synopsis

The NDK is an Nginx module that is designed to extend the core functionality of the excellent Nginx webserver in a way that can be used as a basis of other Nginx modules.

It has functions and macros to deal with generic tasks that don't currently have generic code as part of the core distribution. The NDK itself adds few features that are seen from a user's point of view - it's just designed to help reduce the code that Nginx module developers need to write.

Nginx module developers wishing to use any of the features in the NDK should specify that the NDK is a dependency of their module, and that users will need to compile it as well when they compile their own modules. They will also need to declare in their own modules which features of the NDK they wish to use (explained below).

If you are not an Nginx module developer, then the only useful part of this project will be the 'usage for users' section below.

Back to TOC

Status

The NDK is now considered to be stable. It is already being used in quite a few third party modules (see list below).

Back to TOC

Features

  • additional conf_set functions for regexes, complex/script values, paths...
  • macros to simplify tasks like checking for NULL values when doing ngx_array_push
  • patches to the main source code
  • ngx_auto_lib_core generic external library handler is included (see separate readme)

Back to TOC

Design

modular

The kit itself is designed in a modular way, so that only the required code is compiled. It's possible to add just a single NDK module, a few or all of them.

Back to TOC

auto-generated & easily extensible

Many of the macros available in the NDK are auto-generated from simple configuration files. This makes creating similar macros for your own code very simple - it's usually just the case of adding an extra line to a config file and re-running the build script.

Back to TOC

Usage for users

If another Nginx module you wish to use specifies that the NDK is a dependency, you will need to do the following :

  1. download the source (https://github.com/simpl/ngx_devel_kit)
  2. unpack the source (tar -xzf $name)
  3. compile Nginx with the following extra option --add-module=/path/to/ngx_devel_kit.

e.g.

./configure --add-module=/path/to/ngx_devel_kit \
            --add-module=/path/to/another/module

Back to TOC

Building as a dynamic module

Starting from NGINX 1.9.11, you can also compile this module as a dynamic module, by using the --add-dynamic-module=PATH option instead of --add-module=PATH on the ./configure command line above. And then you can explicitly load the module in your nginx.conf via the load_module directive, for example,

load_module /path/to/modules/ndk_http_module.so;
load_module /path/to/another/module.so;

Back to TOC

Usage for developers

To use the NDK in your own module, you need to add the following:

  1. add this line to your module
#include    <ndk.h>

Note: since the NDK includes the following lines

#include    <ngx_config.h>
#include    <ngx_core.h>
#include    <ngx_http.h>

you can replace these with the single include above. 2. add the following line in the config file for your module:

have=NDK_[module_name]  . auto/have

for each NDK module that you wish to use (you need to include auto/have multiple times if you wish to use multiple NDK modules.

Note: the old method of setting

CFLAGS="$CFLAGS -DNDK_[module_name]"

is now deprecated. It will still work, but results in unnecessary lines being displayed when compiling Nginx.

Back to TOC

Warning: Using NDK_ALL

You can also set NDK_ALL to include all the NDK modules. This is primarily as a convenience in the early stages of development of another module. However,

DO NOT LEAVE NDK_ALL IN YOUR CONFIG FILE WHEN PUBLISHING

Although the NDK is fairly small now, it could in time become a large repository of code that would, if using NDK_ALL, result in considerably more code being compiled than is necessary.

Back to TOC

Modules using NDK

The following 3rd-party modules make use of NDK.

If you would like to add your module to this list, please let us know.

Back to TOC

TODO

  • documentation for modules that don't already have it
  • additional phase-handler functions
  • generically testing for needing to add a handler
  • remove dependency of set_var on OpenSSL being compiled in
  • for backward compatability, add the ndk_macros

Back to TOC

License

Copyright (c) 2010-2018, Marcus Clyne

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Back to TOC

Contributing / Feedback

If you are an Nginx module developer, and have developed some functions that are generic in nature (or would be easily adapted to be so), then please send them to me at the address below, and I'll addmclyne to the kit.

Back to TOC

Author

Marcus Clyne

Back to TOC

Special Thanks

A special thanks goes to Yichun Zhang for helping to maintain this module.

Back to TOC

ngx_devel_kit's People

Contributors

agentzh avatar chaoslawful avatar chobits avatar defanator avatar kolbyjack avatar lynch1981 avatar orgads avatar piotrsikora avatar simpl avatar zhuizhuhaomeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx_devel_kit's Issues

nginx 1.10 error

./configure --add-module=../ngx_devel_kit-master --add-module=../set-misc-nginx-module-master
make
cc -c -fPIC -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -DNDK_SET_VAR -DNDK_UPSTREAM_LIST -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_devel_kit-master/objs -I objs/addon/ndk -I ../ngx_devel_kit-master/src -I ../ngx_devel_kit-master/objs -I objs/addon/ndk -I objs -I src/http -I src/http/modules -I ../ngx_devel_kit-master/src
-o objs/addon/src/ndk.o
../ngx_devel_kit-master/src/ndk.c
In file included from ../ngx_devel_kit-master/src/ndk.c:6:0:
../ngx_devel_kit-master/src/ndk.h:36:27: fatal error: ndk_config.h: No such file or directory
#include <ndk_config.h>
^
compilation terminated.
objs/Makefile:1174: recipe for target 'objs/addon/src/ndk.o' failed
make[1]: *** [objs/addon/src/ndk.o] Error 1
make[1]: Leaving directory '/home/pkg/nginx-1.10.1'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2

ndk_conf_set_http_complex_value_slot() assignment issue.

hi,
it's a minor detail, but looks like in ndk_conf_set_http_complex_value_slot() :
cf->value = value[1] is not necessary, it seems like it will be overwritten by "value" in ngx_http_compile_complex_value() called by ndk_http_complex_value_compile()
also ndk_http_complex_value_compile should be called with &value[1] rather than "value", otherwise the name of the directive ends up in the value field.

here is my proposed patch (btw, trailing whitespace in your code causes "blank line" diffs):

 ngx_int_t
@@ -78,7 +78,7 @@ ndk_conf_set_http_complex_value_slot (ngx_conf_t *cf, ngx_command_t *cmd, void *
     ngx_http_complex_value_t    *cv;
     ngx_str_t                   *value;
     ngx_conf_post_t             *post;
-
+
     cv = (ngx_http_complex_value_t *) (p + cmd->offset);

     if (cv->value.data) {
@@ -87,10 +87,9 @@ ndk_conf_set_http_complex_value_slot (ngx_conf_t *cf, ngx_command_t *cmd, void *

     value = cf->args->elts;

-    cv->value = value[1];
-
-    if (ndk_http_complex_value_compile (cf, cv, value))
+    if (ndk_http_complex_value_compile (cf, cv, &value[1])) {
         return  NGX_CONF_ERROR;
+    }

     if (cmd->post) {
         post = cmd->post;

can't install ndk.

Hi, i download it and use command line to install it.

brew install nginx-full --add-modul=xxxx/ngx_devel_kit/src

start nginx still get error like below
nginx: [emerg] unknown directive "set_by_lua"

how to do it, please help.thanks

rc1 -> release

Just wondering if the release candidate can turn into an official release.
We've been using this for a while, and haven't seen any issues.

Is anything keeping a release from happening?

Nginx 1.9.0 Compilation

ngx_http_lua_timer.c:351: undefined reference to `ngx_http_set_connection_log'

When performing "make"

It forces the compiler to exit out.

The issue is not there on nginx 1.8.0

compile errors

here is my build script

lynch@ngx-dev:~/workspace/nginx-1.20.1$ cat build
mod_path=/home/lynch/workspace
./configure --with-debug
--with-cc-opt='-O0'
--add-module=$mod_path/ngx_devel_kit-0.3.2
--add-module=$mod_path/echo-nginx-module-0.36
make -j 2

I enabled all ndk modules in echo-nginx-module
have=NDK_ALL . auto/have

got several compile errors
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -O0 -I src/core -I src/event -I src/event/modules -I src/os/unix -I /home/lynch/workspace/ngx_devel_kit-0.3.2/objs -I objs/addon/ndk -I objs -I src/http -I src/http/modules -I /home/lynch/workspace/ngx_devel_kit-0.3.2/src -I /home/lynch/workspace/ngx_devel_kit-0.3.2/src -I /home/lynch/workspace/ngx_devel_kit-0.3.2/objs -I objs/addon/ndk
-o objs/addon/src/ndk.o
/home/lynch/workspace/ngx_devel_kit-0.3.2/src/ndk.c
In file included from src/core/ngx_core.h:52,
from /home/lynch/workspace/ngx_devel_kit-0.3.2/src/ndk.h:12,
from /home/lynch/workspace/ngx_devel_kit-0.3.2/src/ndk.c:6:
/home/lynch/workspace/ngx_devel_kit-0.3.2/src/ndk_conf_file.c: In function ‘ndk_replace_command’:
/home/lynch/workspace/ngx_devel_kit-0.3.2/src/ndk_string_util.h:13:66: error: argument to ‘sizeof’ in ‘memcpy’ call is the same pointer type ‘ngx_command_t *’ {aka ‘struct ngx_command_s *’} as the destination; expected ‘ngx_command_t’ {aka ‘struct ngx_command_s’} or an explicit length [-Werror=sizeof-pointer-memaccess]
13 | #define ndk_memcpyp(d,s) ngx_memcpy(d,s,sizeof(s))
| ^
src/core/ngx_string.h:106:59: note: in definition of macro ‘ngx_memcpy’
106 | #define ngx_memcpy(dst, src, n) (void) memcpy(dst, src, n)
| ^
/home/lynch/workspace/ngx_devel_kit-0.3.2/src/ndk_conf_file.c:389:17: note: in expansion of macro ‘ndk_memcpyp’
389 | ndk_memcpyp (cmd, new_cmd);
| ^~~~~~~~~~~
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -O0 -I src/core -I src/event -I src/event/modules -I src/os/unix -I /home/lynch/workspace/ngx_devel_kit-0.3.2/objs -I objs/addon/ndk -I objs -I src/http -I src/http/modules -I /home/lynch/workspace/ngx_devel_kit-0.3.2/src -I /home/lynch/workspace/ngx_devel_kit-0.3.2/src -I /home/lynch/workspace/ngx_devel_kit-0.3.2/objs -I objs/addon/ndk
-o objs/addon/src/ngx_http_echo_module.o
/home/lynch/workspace/echo-nginx-module-0.36/src/ngx_http_echo_module.c
In file included from /home/lynch/workspace/ngx_devel_kit-0.3.2/objs/ndk_config.c:20,
from /home/lynch/workspace/ngx_devel_kit-0.3.2/src/ndk.c:8:
/home/lynch/workspace/ngx_devel_kit-0.3.2/src/ndk.c: In function ‘ndk_conf_set_http_complex_path_slot’:
/home/lynch/workspace/ngx_devel_kit-0.3.2/src/ndk_complex_path.c:122:17: error: ‘a’ may be used uninitialized [-Werror=maybe-uninitialized]
122 | return post->post_handler (cf, post, a);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -O0 -I src/core -I src/event -I src/event/modules -I src/os/unix -I /home/lynch/workspace/ngx_devel_kit-0.3.2/objs -I objs/addon/ndk -I objs -I src/http -I src/http/modules -I /home/lynch/workspace/ngx_devel_kit-0.3.2/src -I /home/lynch/workspace/ngx_devel_kit-0.3.2/src -I /home/lynch/workspace/ngx_devel_kit-0.3.2/objs -I objs/addon/ndk
-o objs/addon/src/ngx_http_echo_util.o
/home/lynch/workspace/echo-nginx-module-0.36/src/ngx_http_echo_util.c
cc1: all warnings being treated as errors
make[1]: *** [objs/Makefile:1239: objs/addon/src/ndk.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/lynch/workspace/nginx-1.20.1'
make: *** [Makefile:10: build] Error 2

i tried to fix them, here is my patch

patch.txt

NGINX 1.17.10 Compilation Error

I am attempting to use set-misc-nginx-module, but this module is a requirement. If it makes a difference, I use BoringSSL (this is a requirement in my scenario).

I build with Clang and the following:

CPPFLAGS="-D_FORTIFY_SOURCE=2"
export CFLAGS="-O3 -pipe -fno-plt"
export CXXFLAGS="-O3 -pipe -fno-plt"
LDFLAGS="-fuse-ld=lld -Wl,--as-needed,-O1,--sort-common,-z,now,-z,relro"

./auto/configure \
...
	--with-cc-opt="$CFLAGS $CPPFLAGS" \
	--with-ld-opt="$LDFLAGS" \
make

However, the same occurs with GCC setup with the following:

CPPFLAGS="-D_FORTIFY_SOURCE=2"
export CFLAGS="-O2 -pipe -fno-plt"
export CXXFLAGS="-O2 -pipe -fno-plt"
LDFLAGS="-Wl,--as-needed,-O1,--sort-common,-z,now,-z,relro"

Building with or without -DNDK_ALL I get the following error:

In file included from ../ngx_devel_kit/src/ndk.c:8:
In file included from ../ngx_devel_kit/objs/ndk_config.c:26:
../ngx_devel_kit/src/ndk_conf_file.c:389:17: warning: argument to 'sizeof' in 'memcpy' call is the same pointer type 'ngx_command_t *' (aka 'struct ngx_command_s *') as the destination; expected 'ngx_command_t' (aka 'struct ngx_command_s') or an explicit length [-Wsizeof-pointer-memaccess]
                ndk_memcpyp (cmd, new_cmd);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~
../ngx_devel_kit/src/ndk_string_util.h:13:60: note: expanded from macro 'ndk_memcpyp'
#define     ndk_memcpyp(d,s)                ngx_memcpy(d,s,sizeof(s))
                                            ~~~~~~~~~~~~~~~^~~~~~~~~~
src/core/ngx_string.h:106:59: note: expanded from macro 'ngx_memcpy'
#define ngx_memcpy(dst, src, n)   (void) memcpy(dst, src, n)
                                                ~~~       ^
In file included from ../ngx_devel_kit/src/ndk.c:8:
In file included from ../ngx_devel_kit/objs/ndk_config.c:32:
../ngx_devel_kit/src/ndk_hash.c:27:5: error: use of undeclared identifier 'MD5_DIGEST_LENGTH'
    NDK_OPENSSL_HASH (MD5, MD5, 0);
    ^
../ngx_devel_kit/src/ndk_hash.c:9:29: note: expanded from macro 'NDK_OPENSSL_HASH'
    u_char              md [ctxt_type ## _DIGEST_LENGTH];           \
                            ^
<scratch space>:61:1: note: expanded from here
MD5_DIGEST_LENGTH
^
In file included from ../ngx_devel_kit/src/ndk.c:8:
In file included from ../ngx_devel_kit/objs/ndk_config.c:32:
../ngx_devel_kit/src/ndk_hash.c:27:5: error: variable has incomplete type 'MD5_CTX' (aka 'struct md5_state_st')
../ngx_devel_kit/src/ndk_hash.c:10:25: note: expanded from macro 'NDK_OPENSSL_HASH'
    ctxt_type ##_CTX    c;                                          \
                        ^
../quiche/deps/boringssl/.openssl/include/openssl/base.h:402:16: note: forward declaration of 'struct md5_state_st'
typedef struct md5_state_st MD5_CTX;
               ^
In file included from ../ngx_devel_kit/src/ndk.c:8:
In file included from ../ngx_devel_kit/objs/ndk_config.c:32:
../ngx_devel_kit/src/ndk_hash.c:27:5: warning: implicit declaration of function 'MD5_Init' is invalid in C99 [-Wimplicit-function-declaration]
    NDK_OPENSSL_HASH (MD5, MD5, 0);
    ^
../ngx_devel_kit/src/ndk_hash.c:12:5: note: expanded from macro 'NDK_OPENSSL_HASH'
    type ## _Init (&c);                                             \
    ^
<scratch space>:63:1: note: expanded from here
MD5_Init
^
In file included from ../ngx_devel_kit/src/ndk.c:8:
In file included from ../ngx_devel_kit/objs/ndk_config.c:32:
../ngx_devel_kit/src/ndk_hash.c:27:5: warning: implicit declaration of function 'MD5_Update' is invalid in C99 [-Wimplicit-function-declaration]
../ngx_devel_kit/src/ndk_hash.c:13:5: note: expanded from macro 'NDK_OPENSSL_HASH'
    type ## _Update (&c, data, len);                                \
    ^
<scratch space>:64:1: note: expanded from here
MD5_Update
^
In file included from ../ngx_devel_kit/src/ndk.c:8:
In file included from ../ngx_devel_kit/objs/ndk_config.c:32:
../ngx_devel_kit/src/ndk_hash.c:27:5: warning: implicit declaration of function 'MD5_Final' is invalid in C99 [-Wimplicit-function-declaration]
../ngx_devel_kit/src/ndk_hash.c:14:5: note: expanded from macro 'NDK_OPENSSL_HASH'
    type ## _Final (md, &c);                                        \
    ^
<scratch space>:65:1: note: expanded from here
MD5_Final
^
In file included from ../ngx_devel_kit/src/ndk.c:8:
In file included from ../ngx_devel_kit/objs/ndk_config.c:32:
../ngx_devel_kit/src/ndk_hash.c:27:5: error: use of undeclared identifier 'MD5_DIGEST_LENGTH'
../ngx_devel_kit/src/ndk_hash.c:16:37: note: expanded from macro 'NDK_OPENSSL_HASH'
    ndk_hex_dump (p, (u_char *) md, ctxt_type ## _DIGEST_LENGTH);   \
                                    ^
<scratch space>:66:1: note: expanded from here
MD5_DIGEST_LENGTH
^
In file included from ../ngx_devel_kit/src/ndk.c:8:
In file included from ../ngx_devel_kit/objs/ndk_config.c:32:
../ngx_devel_kit/src/ndk_hash.c:27:5: error: use of undeclared identifier 'MD5_DIGEST_LENGTH'
../ngx_devel_kit/src/ndk_hash.c:18:29: note: expanded from macro 'NDK_OPENSSL_HASH'
        ndk_strtoupper (p, (ctxt_type ## _DIGEST_LENGTH) *2);       \
                            ^
<scratch space>:67:1: note: expanded from here
MD5_DIGEST_LENGTH
^
In file included from ../ngx_devel_kit/src/ndk.c:8:
In file included from ../ngx_devel_kit/objs/ndk_config.c:32:
../ngx_devel_kit/src/ndk_hash.c:33:5: error: use of undeclared identifier 'MD5_DIGEST_LENGTH'
    NDK_OPENSSL_HASH (MD5, MD5, 1);
    ^
../ngx_devel_kit/src/ndk_hash.c:9:29: note: expanded from macro 'NDK_OPENSSL_HASH'
    u_char              md [ctxt_type ## _DIGEST_LENGTH];           \
                            ^
<scratch space>:68:1: note: expanded from here
MD5_DIGEST_LENGTH
^

Compilation issue with --with-http_perl_module

There is an error when compiling with the embedded perl module for nginx.

The Makefile for perl doesn't include the paths for 3rd party modules, and thus doesn't know where to find ndk_config.h included in ngx_config.h

make error `undefined reference to `ngx_http_rewrite_module'`

Hello,

I have run in to the following issue when compiling nginx with ndk and lua-nginx-module. I am using ngx devel kit 0.3.0 and lua nginx module 0.10.7

./configure
  --without-http_rewrite_module \
  --prefix=/usr/share/nginx \
  --sbin-path=/usr/sbin/nginx \
  --modules-path=/usr/lib64/nginx/modules \
  --conf-path=/etc/nginx/nginx.conf \
  --error-log-path=/var/log/nginx/error.log \
  --http-log-path=/var/log/nginx/access.log \
  --http-client-body-temp-path=/var/lib/nginx/tmp/client_body \
  --http-proxy-temp-path=/var/lib/nginx/tmp/proxy \
  --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi \
  --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi \
  --http-scgi-temp-path=/var/lib/nginx/tmp/scgi \
  --pid-path=/run/nginx.pid \
  --lock-path=/run/lock/subsys/nginx \
  --user=nginx \
  --group=nginx \
  --with-file-aio \
  --with-ipv6 \
  --with-http_ssl_module \
  --with-http_v2_module \
  --with-http_realip_module \
  --with-http_addition_module \
  --with-http_xslt_module=dynamic \
  --with-http_image_filter_module=dynamic\
  --with-http_geoip_module=dynamic \
  --with-http_sub_module \
  --with-http_dav_module \
  --with-http_flv_module \
  --with-http_mp4_module \
  --with-http_gunzip_module \
  --with-http_gzip_static_module \
  --with-http_random_index_module \
  --with-http_secure_link_module \
  --with-http_degradation_module \
  --with-http_slice_module \
  --with-http_stub_status_module \
  --with-http_perl_module=dynamic \
  --with-mail=dynamic \
  --with-mail_ssl_module \
  --with-pcre \
  --with-pcre-jit \
  --with-stream=dynamic \
  --with-stream_ssl_module \
  --with-google_perftools_module \
  --with-debug \
  --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' \
  --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E -Wl,-rpath,/usr/local/include/luajit-2.0' \
  --add-module=/root/nginx-lua/ngx_devel_kit-0.3.0 \
  --add-module=/root/nginx-lua/lua-nginx-module-0.10.7

Configuring works fine, but as soon as I make:

objs/ngx_modules.o \
-L/usr/local/lib/ -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E -Wl,-rpath,/usr/local/include/luajit-2.0 -Wl,-E -ldl -lpthread -lcrypt -L/usr/local/lib/ -lluajit-5.1 -lm -ldl -lpcre -lssl -lcrypto -ldl -lz -lprofiler \
-Wl,-E
objs/addon/src/ndk.o: In function `ndk_set_var_name':
/root/nginx-lua/ngx_devel_kit-0.3.0/src/ndk_set_var.c:267: undefined reference to `ngx_http_rewrite_module'
objs/addon/src/ndk.o: In function `ndk_http_rewrite_var':
/root/nginx-lua/ngx_devel_kit-0.3.0/src/ndk_rewrite.c:78: undefined reference to `ngx_http_rewrite_module'
collect2: error: ld returned 1 exit status
make[1]: *** [objs/nginx] Error 1
make[1]: Leaving directory `/root/nginx-lua/nginx-1.10.2'
make: *** [build] Error 2

Any clue what I'm doing wrong?

error with set_misc

Hi! After update this module don`t work with ngx_http_set_misc_module

nginx: [emerg] dlopen() "/etc/nginx/modules/ngx_http_set_misc_module.so" failed (/etc/nginx/modules/ngx_http_set_misc_module.so: undefined symbol: ndk_set_var_value) in /etc/nginx/nginx.conf:12
nginx: configuration file /etc/nginx/nginx.conf test failed

is there something wrong?

    -L/compile/openresty-1.9.7.4/build/luajit-root/usr/local/nginx/luajit/lib -Wl,-rpath,/usr/local/nginx/luajit/lib -Wl,-E -ldl -lpthread -lcrypt -L/compile/openresty-1.9.7.4/build/luajit-root/usr/local/nginx/luajit/lib -lluajit-5.1 -lm -ldl -lmaxminddb -lmcrypt -lpcre -lssl -lcrypto -ldl -lz -lGeoIP \
    -Wl,-E
objs/addon/src/ndk.o: In function `ndk_set_var_code':
/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_set_var.c:83: multiple definition of `ndk_http_script_exit_code'
objs/addon/src/ndk.o:/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_set_var.c:83: first defined here
objs/addon/src/ndk.o: In function `ndk_get_upstream_list':
/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_upstream_list.c:185: multiple definition of `ndk_get_upstream_list'
objs/addon/src/ndk.o:/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_upstream_list.c:185: first defined here
objs/addon/src/ndk.o:(.data+0x40): multiple definition of `ndk_http_module'
objs/addon/src/ndk.o:(.data+0x40): first defined here
objs/addon/src/ndk.o: In function `ndk_http_rewrite_var':
/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_rewrite.c:73: multiple definition of `ndk_http_rewrite_var'
objs/addon/src/ndk.o:/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_rewrite.c:73: first defined here
objs/addon/src/ndk.o: In function `ndk_set_var_core':
/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_set_var.c:494: multiple definition of `ndk_set_var_core'
objs/addon/src/ndk.o:/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_set_var.c:494: first defined here
objs/addon/src/ndk.o: In function `ndk_set_var':
/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_set_var.c:564: multiple definition of `ndk_set_var'
objs/addon/src/ndk.o:/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_set_var.c:564: first defined here
objs/addon/src/ndk.o: In function `ndk_http_rewrite_value':
/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_rewrite.c:15: multiple definition of `ndk_http_rewrite_value'
objs/addon/src/ndk.o:/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_rewrite.c:15: first defined here
objs/addon/src/ndk.o: In function `ndk_set_var_multi_value_core':
/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_set_var.c:534: multiple definition of `ndk_set_var_multi_value_core'
objs/addon/src/ndk.o:/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_set_var.c:534: first defined here
objs/addon/src/ndk.o: In function `ndk_set_var_multi_value':
/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_set_var.c:595: multiple definition of `ndk_set_var_multi_value'
objs/addon/src/ndk.o:/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_set_var.c:595: first defined here
objs/addon/src/ndk.o: In function `ndk_set_var_value_core':
/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_set_var.c:511: multiple definition of `ndk_set_var_value_core'
objs/addon/src/ndk.o:/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_set_var.c:511: first defined here
objs/addon/src/ndk.o: In function `ndk_set_var_value':
/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_set_var.c:579: multiple definition of `ndk_set_var_value'
objs/addon/src/ndk.o:/compile/openresty-1.9.7.4/build/nginx-1.9.13/../ngx_devel_kit-0.3.0rc1/src/ndk_set_var.c:579: first defined here
objs/addon/src/ndk.o:(.data+0x0): multiple definition of `ndk_http_module_ctx'
objs/addon/src/ndk.o:(.data+0x0): first defined here
collect2: ld return 1
make[2]: *** [objs/nginx] error 1
make[2]: Leaving directory `/compile/openresty-1.9.7.4/build/nginx-1.9.13'
make[1]: *** [build] error 2
make[1]: Leaving directory `/compile/openresty-1.9.7.4/build/nginx-1.9.13'
make: *** [all] error 2

error=sizeof-pointer-memaccess

I'm on ubuntu Bionic and tried to compile as static module. Configure works fine, but when compiling with make, I get this error here ...

Using GCC-7 ... Same error with GCC-8

cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I /home/maarten/src/nginx-1.14.0/addons/ngx_devel_kit/objs -I objs/addon/ndk -I objs -I src/http -I src/http/modules -I /usr/local/passenger-5.3.5/src -I /home/maarten/src/nginx-1.14.0/addons/ngx_devel_kit/src -I /home/maarten/src/nginx-1.14.0/addons/ngx_devel_kit/src -I /home/maarten/src/nginx-1.14.0/addons/ngx_devel_kit/objs -I objs/addon/ndk -I src/mail
-o objs/addon/src/ndk.o
/home/maarten/src/nginx-1.14.0/addons/ngx_devel_kit/src/ndk.c
In file included from src/core/ngx_core.h:50:0,
from /home/maarten/src/nginx-1.14.0/addons/ngx_devel_kit/src/ndk.h:12,
from /home/maarten/src/nginx-1.14.0/addons/ngx_devel_kit/src/ndk.c:6:
/home/maarten/src/nginx-1.14.0/addons/ngx_devel_kit/src/ndk_conf_file.c: In function 'ndk_replace_command':
/home/maarten/src/nginx-1.14.0/addons/ngx_devel_kit/src/ndk_string_util.h:13:66: error: argument to 'sizeof' in 'memcpy' call is the same pointer type 'ngx_command_t * {aka struct ngx_command_s *}' as the destination; expected 'ngx_command_t {aka struct ngx_command_s}' or an explicit length [-Werror=sizeof-pointer-memaccess]
#define ndk_memcpyp(d,s) ngx_memcpy(d,s,sizeof(s))
^
src/core/ngx_string.h:104:59: note: in definition of macro 'ngx_memcpy'
#define ngx_memcpy(dst, src, n) (void) memcpy(dst, src, n)
^
/home/maarten/src/nginx-1.14.0/addons/ngx_devel_kit/src/ndk_conf_file.c:389:17: note: in expansion of macro 'ndk_memcpyp'
ndk_memcpyp (cmd, new_cmd);
^~~~~~~~~~~
cc1: all warnings being treated as errors
objs/Makefile:1434: recipe for target 'objs/addon/src/ndk.o' failed
make[1]: *** [objs/addon/src/ndk.o] Error 1
make[1]: Leaving directory '/home/maarten/src/nginx-1.14.0'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2

How to start

I want to write a module over Nginx.
First I tried with cloning Nginx and writing my module in it, every time I was getting import error for #include <ngx_config.h>.
Then I found NDK. But when I am importing NDK into eclipse for c then too I am getting same error.
Need help to take first step. How to use it.

  1. How can I start to develop a module with NDK and run it....
  2. How to compile NDK

Fail to link module with nginx as dynamic library

Hi,
I am facing problem with this module, module successfully complited but when i configure this with NGINX, I am getting below error.
I have successfully complied and configured other modules with nginx. But same not working with this, I changed build conguration, still no success. Please help

## ERROR
nginx: [emerg] module "/etc/nginx/modules/ndk_http_module.so" is not binary compatible in /etc/nginx/nginx.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed

## NGINX build configuration

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' --add-dynamic-module=../ngx_devel_kit-master/ --add-dynamic-module=../lua-nginx-module-master/

nginx: [emerg] unknown directive "ELF" in ndk_http_module.so:4

Tried to compile and use on arch linux and I keep getting ' unknown directive "ELF" '.

nginx -t

nginx: [emerg] unknown directive "ELF" in ndk_http_module.so:4
nginx: configuration file nginx.conf test failed
nginx -V

nginx version: nginx/1.21.1
built by gcc 11.1.0 (GCC) 
built with OpenSSL 1.1.1k  25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=~/nginx --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_secure_link_module --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module --with-stream_realip_module --with-stream_geoip_module --with-compat --with-pcre=~/pkgs/pcre --with-pcre-jit --with-threads --with-zlib=~/pkgs/zlib --with-openssl=~/pkgs/openssl --add-dynamic-module=~/mods/ngx_devel_kit --add-dynamic-module=~/mods/ngx_http_auth_pam_module --add-dynamic-module=~/mods/ngx_brotli --add-dynamic-module=~/mods/ngx_dynamic_limit_req_module --add-dynamic-module=~/mods/ngx_cookie_limit_req_module --add-dynamic-module=~/mods/form-input-nginx-module --add-dynamic-module=~/mods/lua-nginx-module --add-dynamic-module=~/mods/lua-ssl-nginx-module --add-dynamic-module=~/mods/redis2-nginx-module --add-dynamic-module=~/mods/stream-lua-nginx-module
uname -a

Linux archserver 5.12.14-arch1-1 #1 SMP PREEMPT Thu, 01 Jul 2021 07:26:06 +0000 x86_64 GNU/Linux

Issue with building RPM package (undefined symbol: ndk_set_var_value)

Hello,

I have tried to build separate rpm package from this spec.

But when I install rpm package and try to use it with ngx_http_lua_module I got following error:

[root@5afe4843ca60 /]# grep load_module /etc/nginx/nginx.conf
load_module modules/ndk_http_module.so;
load_module modules/ngx_http_lua_module.so;

[root@5afe4843ca60 /]# nginx -t -c /etc/nginx/nginx.conf
nginx: [emerg] dlopen() "/etc/nginx/modules/ngx_http_lua_module.so" failed (/etc/nginx/modules/ngx_http_lua_module.so: undefined symbol: ndk_set_var_value) in /etc/nginx/nginx.conf:9
nginx: configuration file /etc/nginx/nginx.conf test failed

Could you please advice me what can be the issue?

Thanks in advance.

Is version v0.3.1 compatible with nginx 1.15?

Hi,

Please let me know if ngx_devel_kit version v0.3.1 compatible and tested with nginx 1.15? What version of nginx do you recommend?

Also, I am trying to use this in a docker container. What are the libraries needed to install this module?

Regards,
Muthu.

couple of cppcheck issues

[src/ndk_regex.c:127]: (error) Uninitialized variable: n
[src/ndk_regex.c:189]: (error) Uninitialized variable: n

look weird, for loop with "n" undefined. I've no idea how to fix that.

compile error

[root@webgw01 openresty-1.9.7.4]# make
cd /data/soft/openresty-1.9.7.4/build/LuaJIT-2.1-20160108 && make TARGET_STRIP=@: CCDEBUG=-g CC=cc PREFIX=/usr/local/openresty/luajit
make[1]: 进入目录“/data/soft/openresty-1.9.7.4/build/LuaJIT-2.1-20160108”
==== Building LuaJIT 2.1.0-beta1 ====
make -C src
make[2]: 进入目录“/data/soft/openresty-1.9.7.4/build/LuaJIT-2.1-20160108/src”
make[2]: 对“default”无需做任何事。
make[2]: 离开目录“/data/soft/openresty-1.9.7.4/build/LuaJIT-2.1-20160108/src”
==== Successfully built LuaJIT 2.1.0-beta1 ====
make[1]: 离开目录“/data/soft/openresty-1.9.7.4/build/LuaJIT-2.1-20160108”
cd /data/soft/openresty-1.9.7.4/build/lua-cjson-2.1.0.3 && make DESTDIR= LUA_INCLUDE_DIR=/data/soft/openresty-1.9.7.4/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.1 LUA_CMODULE_DIR=/usr/local/openresty/lualib LUA_MODULE_DIR=/usr/local/openresty/lualib CJSON_CFLAGS="-g -fpic" CC=cc
make[1]: 进入目录“/data/soft/openresty-1.9.7.4/build/lua-cjson-2.1.0.3”
cc -c -O3 -Wall -pedantic -DNDEBUG -I/data/soft/openresty-1.9.7.4/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.1 -g -fpic -o lua_cjson.o lua_cjson.c
cc -c -O3 -Wall -pedantic -DNDEBUG -I/data/soft/openresty-1.9.7.4/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.1 -g -fpic -o strbuf.o strbuf.c
cc -c -O3 -Wall -pedantic -DNDEBUG -I/data/soft/openresty-1.9.7.4/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.1 -g -fpic -o fpconv.o fpconv.c
cc -shared -o cjson.so lua_cjson.o strbuf.o fpconv.o
make[1]: 离开目录“/data/soft/openresty-1.9.7.4/build/lua-cjson-2.1.0.3”
cd /data/soft/openresty-1.9.7.4/build/lua-redis-parser-0.12 && make DESTDIR= LUA_INCLUDE_DIR=/data/soft/openresty-1.9.7.4/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.1 LUA_LIB_DIR=/usr/local/openresty/lualib CC=cc
make[1]: 进入目录“/data/soft/openresty-1.9.7.4/build/lua-redis-parser-0.12”
cc -c -g -O -Wall -fpic -I/data/soft/openresty-1.9.7.4/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.1 -o redis-parser.o redis-parser.c
cc -shared -o parser.so redis-parser.o
make[1]: 离开目录“/data/soft/openresty-1.9.7.4/build/lua-redis-parser-0.12”
cd /data/soft/openresty-1.9.7.4/build/lua-rds-parser-0.06 && make DESTDIR= LUA_INCLUDE_DIR=/data/soft/openresty-1.9.7.4/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.1 LUA_LIB_DIR=/usr/local/openresty/lualib CC=cc
make[1]: 进入目录“/data/soft/openresty-1.9.7.4/build/lua-rds-parser-0.06”
cc -c -g -O -Wall -fpic -I/data/soft/openresty-1.9.7.4/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.1 -o src/rds_parser.o src/rds_parser.c
cc -shared -o parser.so src/rds_parser.o
make[1]: 离开目录“/data/soft/openresty-1.9.7.4/build/lua-rds-parser-0.06”
cd /data/soft/openresty-1.9.7.4/build/nginx-1.9.7 && make
make[1]: 进入目录“/data/soft/openresty-1.9.7.4/build/nginx-1.9.7”
make -f objs/Makefile
make[2]: 进入目录“/data/soft/openresty-1.9.7.4/build/nginx-1.9.7”
objs/Makefile:131: *** 遗漏分隔符 (您的意思是用 TAB 代替 8 个空格?)。 停止。
make[2]: 离开目录“/data/soft/openresty-1.9.7.4/build/nginx-1.9.7”
make[1]: *** [build] 错误 2
make[1]: 离开目录“/data/soft/openresty-1.9.7.4/build/nginx-1.9.7”
make: *** [all] 错误 2
[root@webgw01 openresty-1.9.7.4]#

has new release?

Hi,
It has not been released from 2019.
Just wondering whether there is a new release version.

as same as the issue #26

Differences in downloaded tags

Hello. I don't know if this is a repository-specific issue, or a GitHub issue. I have already e-mailed GitHub about this. I am posting here just in case.

Here is what I am seeing:

I go here:
https://github.com/vision5/ngx_devel_kit/releases

And I download the file at this link:
https://github.com/vision5/ngx_devel_kit/archive/refs/tags/v0.3.1.tar.gz

I can also download the file at this link:
https://github.com/vision5/ngx_devel_kit/archives/refs/tags/v0.3.1.tar.gz

The 2 links are equal, except s/archive/archives/.

And the files downloaded are different sizes.

The file at /archive/ is ~65K.

The file at /archives/ is ~74K.

What is going on?

Cheers,

  • Daniel

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.