Skip to content

Commit

Permalink
updated README to introduce ngx_lua as a better alternative to ngx_eval.
Browse files Browse the repository at this point in the history
  • Loading branch information
agentzh committed Nov 16, 2010
1 parent dca2cdd commit fcdae41
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
28 changes: 25 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ Synopsis

Description

This fork of ngx_eval can work with any content handlers and even with filters enabled
as long as you put ngx_eval *before* your filter modules during nginx configure, for
instance
This fork of ngx_eval can work with any content handlers and
even with filters enabled as long as you put ngx_eval *before*
your filter modules during nginx configure, for instance

./configure --prefix=/opt/nginx \
--add-module=/path/to/this/nginx-eval-module \
Expand All @@ -54,6 +54,10 @@ instance

such that ngx_eval's filter works *after* your filter modules.

Limitations
* The contents of subrequests issued from the eval block won't be
captured properly.

Compatibility
The following versions of Nginx should work with this module:

Expand All @@ -70,6 +74,24 @@ but fortunately a patch is available for nginx 0.8.53:
This one-line patch should also be able to apply cleanly to other versions
of nginx 0.8.42+.

Nowadays we prefer ngx_lua to do the tasks originally done by ngx_eval
because various limitations in ngx_lua (and yeah, it requires patching
the core for nginx 0.8.42+, sigh).

Here's a small example using ngx_lua:

location / {
content_by_lua '
local res = ngx.location.capture('/getbanner')
ngx.print(res)
';
}

location /getbanner {
internal;
proxy_pass http://backend.local:3500;
}

Original ngx_eval documentation:

Documentation for this module could be found under following URLs:
Expand Down
2 changes: 2 additions & 0 deletions config
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ ngx_addon_name=ngx_http_eval_module
HTTP_AUX_FILTER_MODULES="$HTTP_AUX_FILTER_MODULES ngx_http_eval_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_eval_module.c"
CFLAGS="$CFLAGS -DNDK_SET_VAR"
#have=NDK_REWRITE_PHASE . auto/have

7 changes: 4 additions & 3 deletions test/t/sanity.t
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,13 @@ a=[], b=[2], c=[a b c]
=== TEST 10: sanity check
--- config
location /echo {
#eval_subrequest_in_memory off;
eval_subrequest_in_memory off;
#eval_subrequest_in_memory on;
#eval_buffer_size 3;
eval $a {
#echo_before_body BEFORE;
proxy_pass $scheme://127.0.0.1:1234/hi;
proxy_pass $scheme://127.0.0.1:$server_port/hi;
#proxy_pass $scheme://127.0.0.1:1234/hi;
}
echo '!!! [$a]';
}
Expand All @@ -217,5 +219,4 @@ GET /echo
--- response_body
!!! [helloooooooooooooooooooo]
--- timeout: 10
--- SKIP
2 changes: 1 addition & 1 deletion util/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ if [[ "$BUILD_CLEAN" -eq 1 || ! -f Makefile || "$root/config" -nt Makefile || "$
--add-module=$root $opts \
--add-module=$root/../echo-nginx-module \
--add-module=$root/../memc-nginx-module \
--add-module=$root/../ndk-nginx-module \
--with-debug
#--add-module=$root/../vallery/eval-nginx-module \
#--add-module=$root/../ndk-nginx-module \
#--add-module=$home/work/nginx/nginx_upstream_hash-0.3 \
#--without-http_ssi_module # we cannot disable ssi because echo_location_async depends on it (i dunno why?!)

Expand Down

0 comments on commit fcdae41

Please sign in to comment.