Accessing the location configuration of module 2 during post configuration processing of module 1 for a particular server
Rv Rv
rvrv7575 at yahoo.com
Thu Jun 12 05:46:58 UTC 2014
Hello Maxim
Thanks for your response. Here is a related query.
Say in module 1 I have a
typedef struct {
int flag;
ngx_str somestring;
} module1;
flag gets initialized with the following code
{ ngx_string("module1_directive"),
NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_flag_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(module1,configured),
NULL },
somestring gets iniitialized with a handler written in the module (i.e not ngx_conf_set_flag_slot or any inbuilt handler).
In the post configuration, I see that flag is not properly set but somestring is. Flag is properly set during request processing though.
Are the values set during processing of a directive in location struct guaranteed to be set by the time post configuration is executed?
When is the time that one can check for the values set during configuration. I need to test these values to ensure that they are sane when nginx is executed with -t option
Thanks
Hello!
On Tue, Jun 10, 2014 at 02:09:13AM +0800, Rv Rv wrote:
> How do we access the configuration of a an unrelated module in a
> given module. This may be required for example to check if the
> directives pertaining to module 2 were specified in location for
> a particular server that has directives for module 1 in its
> configuration.
I don't think it's something you should do at postconfiguration -
location structure is complex and not easily accessible. There
are location configuration merge callbacks where you are expected
to work with location configs and, in particular, can use
ngx_http_conf_get_module_loc_conf() macro to access a
configuration of other modules (note though, that order of modules
may be important in this case).
[...]
> I did not find any documentation on how the configuration is stored within nginx using these structs?
It's under src/, in C language.
I would rather say it's not a part of the API, and you'd better
avoid using it directly.
--
Maxim Dounin
http://nginx.org/
------------------------------
On Monday, 9 June 2014 11:39 PM, Rv Rv <rvrv7575 at yahoo.com> wrote:
How do we access the configuration of a an unrelated module in a given module. This may be required for example to check if the directives pertaining to module 2 were specified in location for a particular server that has directives for module 1 in its configuration.
From what I understand, code similar to this can be used
/* Get http main configuration */
cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
/* Get the list of servers */
cscfp = cmcf->servers.elts;
/* Iterate through the list */
for (s = 0; s < cmcf->servers.nelts; s++) {
/* Problem : how to get the configuration of module 2*/
cscfp[s]->ctx->loc_conf[module2.ctx_index];-------------> does not yield the correct location struct of module 2
I did not find any documentation on how the configuration is stored within nginx using these structs
typedef struct {
.............
/* server ctx */ ngx_http_conf_ctx_t *ctx; ............
} ngx_http_core_srv_conf_t;
typedef struct {
void **main_conf;
void **srv_conf;
void **loc_conf;
} ngx_http_conf_ctx_t;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20140612/8c6fd6a1/attachment.html>
More information about the nginx
mailing list