Accessing the location configuration of module 2 during post configuration processing of module 1 for a particular server
Maxim Dounin
mdounin at mdounin.ru
Mon Jun 16 14:14:40 UTC 2014
Hello!
On Mon, Jun 16, 2014 at 02:58:50PM +0800, Rv Rv wrote:
> Hello Maxim
> Thanks for the response.
> >>As previously suggested, you should consider using merge callbacks>>to validate configuration instead.
>
> The requirement is *not* to validate the configuration. The
> requirement is to find the final value set by one of the
> directives once the configuration has been parsed. e..g lets say
> we have a directive my_set_flag that sets a value to 0 or 1.
>
> So if in configuration we have
> location \ {
> my_set_flag 0;
> ---
> my_set_flag 1;
> ---
> my_set_flag 0;
> }
Such a configuration is invalid due to duplicate "my_set_flag"
directive, and will be rejected during configuration parsing.
> then the merge callback will be called thrice for each
> invocation of the directive. Let's assume the logic is to set a
> variable with whatever the value of the directive was. So once
> parsing completes, the value of the variable should be 0.
You are misunderstanding what merge callback is, what it does and
how it's called.
> I can get this value during request processing. However, I
> cannot get this value *after* the parsing of the configuration
> has completed. What is the nginx recommended way to get this
> value. As noted in earlier post, I am not seeing the correct
> values in post configuration - and so perhaps that is not the
> right way.
Again: accessing a location configuration from postconfiguration
callback isn't trivial and not supported. You should use merge
callback instead, or use main or server configuration instead,
not location.
Before proceeding any further, I would recommend you to spend some
time digging into nginx configuration basics. In particular, Evan
Miller's guide may be helpful, see links here:
http://nginx.org/en/links.html
--
Maxim Dounin
http://nginx.org/
More information about the nginx
mailing list