openresty / replace-filter-nginx-module

Streaming regular expression replacement in response bodies
260 stars 68 forks source link

compile replace-filter as a dynamic module #18

Closed shmilee closed 8 years ago

shmilee commented 8 years ago

https://github.com/shmilee/web-in-docker/blob/f8a01536ca4a3a7cc2f7f880f58ce21a731f31dd/mynginx/PKGBUILD#L170

Can we add this to config?

sed -i '60,100d' ./config
  cat >> ./config <<'EOF'
if [ $ngx_found = no ]; then
 cat << END
 $0: error: ngx_http_replace_filter_module requires agentzh's sregex library.
END
 exit 1
fi
_REPLACE_SRCS="$ngx_addon_dir/src/ngx_http_replace_filter_module.c \
               $ngx_addon_dir/src/ngx_http_replace_script.c \
               $ngx_addon_dir/src/ngx_http_replace_parse.c \
               $ngx_addon_dir/src/ngx_http_replace_util.c"
_REPLACE_DEPS="$ngx_addon_dir/src/ngx_http_replace_filter_module.h \
               $ngx_addon_dir/src/ngx_http_replace_script.h \
               $ngx_addon_dir/src/ngx_http_replace_parse.h \
               $ngx_addon_dir/src/ngx_http_replace_util.h"
ngx_addon_name=ngx_http_replace_filter_module
if test -n "$ngx_module_link"; then
    ngx_module_type=HTTP_AUX_FILTER
    ngx_module_name=ngx_http_replace_filter_module
    ngx_module_srcs="$_REPLACE_SRCS"
    ngx_module_deps="$_REPLACE_DEPS"
    ngx_module_libs=$ngx_feature_libs
    . auto/module
else
    HTTP_AUX_FILTER_MODULES="$HTTP_AUX_FILTER_MODULES ngx_http_replace_filter_module"
    NGX_ADDON_SRCS="$NGX_ADDON_SRCS $_REPLACE_SRCS"
    NGX_ADDON_DEPS="$NGX_ADDON_DEPS $_REPLACE_DEPS"
    CORE_INCS="$CORE_INCS $ngx_feature_path"
    CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
fi
EOF
[$] ldd `which nginx`                                                                   :) 0
    linux-vdso.so.1 (0x00007fffdc7a4000)
    libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fe8eea73000)
    libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fe8ee856000)
    libcrypt.so.1 => /usr/lib/libcrypt.so.1 (0x00007fe8ee61e000)
    libpcre.so.1 => /usr/lib/libpcre.so.1 (0x00007fe8ee3ab000)
    libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0x00007fe8ee13a000)
    libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0x00007fe8edcc2000)
    libz.so.1 => /usr/lib/libz.so.1 (0x00007fe8edaac000)
    libGeoIP.so.1 => /usr/lib/libGeoIP.so.1 (0x00007fe8ed87a000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00007fe8ed4dc000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fe8eec77000)
[$] ldd /usr/lib/nginx/ngx_http_replace_filter_module.so                                :) 0
    linux-vdso.so.1 (0x00007fff98b99000)
    libsregex.so.0 => /usr/lib/libsregex.so.0 (0x00007f13cb650000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00007f13cb2b2000)
    /usr/lib64/ld-linux-x86-64.so.2 (0x0000562614ea4000)
agentzh commented 8 years ago

@shmilee Looks good to me. Will you create a github pull request please? Thanks!