How to control the order of execution modules in nginx

Fromhttp://www.evanmiller.org/nginx-modules-guide.html, “The order of
their execution is determined at compile-time”. Is there a way to
control this. ngx_modules.c has the list and order of execution. How do
I change the order of execution of modules within a particular phase
e.g. if I have three modules within the access phase, is there a way to
control the order of execution with the access phase.

Hello!

On Thu, Jan 30, 2014 at 01:05:34PM +0800, Rv Rv wrote:

Fromhttp://www.evanmiller.org/nginx-modules-guide.html, “The
order of their execution is determined at compile-time”. Is
there a way to control this. ngx_modules.c has the list and
order of execution. How do I change the order of execution of
modules within a particular phase e.g. if I have three modules
within the access phase, is there a way to control the order of
execution with the access phase.

Order of execution of modules in a particular phase is set during
a configure, modules which are last in HTTP_MODULES are executed
first.

That is, if you want to add “module1”, “module2”, and “module3”,
all of them use the access phase, and each of them does something
like

HTTP_MODULES="$HTTP_MODULES moduleN"

in it’s “config” file, you should do something like

./configure --add-module=module3 \
            --add-module=module2 \
            --add-module=module1

to get the “module1 → module2 → module3” order.

Note that it may non-trivial to, e.g., make sure your module is
called after standard modules in the access phase.


Maxim D.
http://nginx.org/