Forum: NGINX Access to location configs from postconfiguration

Posted by Dmitry Potapov (Guest)
on 2012-12-26 18:59
(Received via mailing list)
Hello,

I'm writing my first nginx module and want perform some per-location
initialization (and validation) in postconfiguration function.
Unfortunately I've found that only named locations can be accessed from
postconfiguration function (using the chain
main_conf->servers->named_locations).
I don't want to force users to named locations usage, so I'm looking for
another way to iterate over locations configs.

For now I've found the following solution:
1. In create_main_conf: create empty array of pointers to
ngx_http_core_loc_conf_t inside module main_conf
2. At the end of each merge_loc_conf function: remove pointer to parent
config from pointers array (if any) and add (or replace) pointer to 
child
config
3. In postconfiguration function: iterate through pointers array from
module main_conf
4. At the end of postconfiguration: free memory used for pointers array

But this seems to be bad solution.
It there any easy and built-in mechanism to iterate over location
configuration, so I can perform initialization for those where my module
was used (and appropriate module location configuration flag was set 
while
parsing)?
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.