<div dir="ltr"><div><div><div><div><div><div>Hello,<br><br>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).<br>
I don't want to force users to named locations usage, so I'm looking for another way to iterate over locations configs.<br><br>For now I've found the following solution:<br>1. In create_main_conf: create empty array of pointers to ngx_http_core_loc_conf_t inside module main_conf<br>
</div>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<br></div>3. In postconfiguration function: iterate through pointers array from module main_conf<br>
</div><div>4. At the end of postconfiguration: free memory used for pointers array<br></div><div><br></div>But this seems to be bad solution.<br></div>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)?<br>
<br>--<br></div>Thanks in advance,<br></div>Dmitry<br></div>