# Access to location configs from postconfiguration

**URL:** <https://www.ruby-forum.com/t/access-to-location-configs-from-postconfiguration/225280>\
**Category:** NGINX\
**Created:** [December 26, 2012, 6:59pm UTC](https://www.ruby-forum.com/t/access-to-location-configs-from-postconfiguration/225280 "2012-12-26T18:59:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [December 26, 2012, 6:59pm UTC](https://www.ruby-forum.com/t/access-to-location-configs-from-postconfiguration/225280/1 "2012-12-26T18:59:41Z")

</div>

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