What is the order of module execution and how can I change it?

Alexander Todorov alexx.todorov at gmail.com
Wed Oct 22 09:26:56 UTC 2014

Hello folks,
I'm looking into nginx for developing custom modules and I'm missing some info 
related to the order of module execution.

At http://www.evanmiller.org/nginx-modules-guide.html it says:
The order of their execution is determined at compile-time. Filters have the 
classic "CHAIN OF RESPONSIBILITY" design pattern: one filter is called, does its 
work, and then calls the next filter, until the final filter is called, and 
Nginx finishes up the response.

Not a mention about non-filter modules. Then when trying to build nginx from 
source I see a objs/ngx_modules.c file with:

ngx_module_t *ngx_modules[] = {

... skip ...


This looks like the order of execution of all modules, is this correct ?

If so, where can I place my modules in this list ? Only at the end or at 
arbitrary positions? How do I do that (point me to docs is fine) ?

For example I'd like to have a custom logging module which executes after 
ngx_http_log_module saving results to a DB for further analysis and BI purposes.

Another example is if I'd want to minify HTML content (a filter module) how do I 
do that before gzip kicks in?

Thanks for any comments or helpers.


More information about the nginx-devel mailing list