Access to location configs from postconfiguration


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
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
  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