Nginx eval module (v 1.0.1)

rus eng

Module for nginx web server evaluates response of proxy or memcached module into variables.

Description

Module executes configuration block specified by eval directive and evaluates the response into variables. The configuration block must contain memcached_pass or proxy_pass directives.

Configuration directives


syntax: eval $<variable1_name> [[ $<variable2_name> ] ... ] {<block>}
default: N/A
severity: mandatory
context: main, server, location

Specifies names of variables to evaluate and block with proxy_pass or memcached_pass directives. The maximal number of variables is 8. Eval block is executed before rewrite module, therefore all configuration of rewrite module must be specified inside eval block. Example:

            location / {
                set $foo bar;

                eval $var {
                    # $foo is empty
                    proxy_pass http://backend/$foo;
                }
            }
		
            location / {
                eval $var {
                    set $foo bar;
                    # $foo is 'bar'
                    proxy_pass http://backend/$foo;
                }
            }
		

For the same reason eval block is ineffective inside if and limit_except blocks, but instead if and limit_except blocks are effective inside eval block.

Evaluation of response into variables is controlled by it's content type (the value of Content-Type header). The following content types are recognized:

In order to override content type returned by the proxy or memcached, it is necessary to use eval_override_content_type directive.


syntax: eval_escalate <on/off>
default: off
severity: optional
context: main, server, location

Enables escalation of error in eval block to upper level of configuration. For example this configuration:

            location / {
                eval_escalate off;

                eval $var {
	            set $foo bar;

                    return 403;
                }

                return 405;
            }
		

returns HTTP error 405, whereas this configuration:

            location / {
                eval_escalate on;

                eval $var {
                    set $foo bar;

                    return 403;
                }

                return 405;
            }
		

returns HTTP error 403.


syntax: eval_override_content_type <mime type>
default: none
severity: optional
context: main, server, location

Specifies content type to use instead of content type provided by memcached or proxy.


Example configuration

eval $var {
    set $memcached_key $1;
    memcached_pass 192.168.2.1;
}
		

Download

Latest version 1.0.1:
FileMD5SHA1
nginx_eval_module-1.0.1.tar.gz570b6f7e40e489c5846ffca725226edbfa1ceef301a83f038ed0fa1ea5634be3c600002d
nginx_eval_module-1.0.1.zipcfda9250f5b596714312a78e314fc94e450e7194c4b226be7a1fdd2285e302d14729bb6f
or go to
download area

Browse repository

http://github.com/vkholodkov/nginx-eval-module/tree/master

How to use

Download sources from one of the links above. Unpack the archive:

tar xvzf nginx_eval_module-1.0.1.tar.gz

Configure nginx with additional module:

cd <path to nginx sources>
./configure --add-module=<path to eval module sources>
make
make install

Nginx

nginx -- is a web-server, developed by Igor Sysoev.

Licence

The licence of above-described module is BSD You should have received a copy of licence along with the source code. If you do not agree to terms and conditions of this licence, you must destroy all copies of module's sources codes on all your computers as well as binary files compiled from those sources.

Contact author

Valery Kholodkov valery+nginx@grid.net.ru
Please use address extension while composing an Email to me.


Copyright (C) 2009 Valery Kholodkov