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[] = {
&ngx_core_module,
&ngx_errlog_module,
&ngx_conf_module,
&ngx_events_module,
&ngx_event_core_module,
&ngx_epoll_module,
&ngx_regex_module,
&ngx_http_module,
&ngx_http_core_module,
&ngx_http_log_module,
... skip ...
&ngx_http_headers_filter_module,
&ngx_http_copy_filter_module,
&ngx_http_range_body_filter_module,
&ngx_http_not_modified_filter_module,
NULL
};
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.
--
Alex
More information about the nginx-devel
mailing list