Welcome! Log In Create A New Profile

Advanced

Access to location configs from postconfiguration

Dmitry Potapov
December 26, 2012 01:00PM
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)?

--
Thanks in advance,
Dmitry
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Access to location configs from postconfiguration

Dmitry Potapov December 26, 2012 01:00PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 301
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready