# Config variable inheritance: docs and rules

**URL:** <https://www.ruby-forum.com/t/config-variable-inheritance-docs-and-rules/218531>\
**Category:** NGINX\
**Created:** [April 3, 2012, 3:14pm UTC](https://www.ruby-forum.com/t/config-variable-inheritance-docs-and-rules/218531 "2012-04-03T15:14:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 3, 2012, 3:14pm UTC](https://www.ruby-forum.com/t/config-variable-inheritance-docs-and-rules/218531/1 "2012-04-03T15:14:45Z")

</div>

Hi all -

[Problem with inheriting fastcgi params - NGINX - Ruby-Forum](http://www.ruby-forum.com/topic/188742) seems to contain some  
information I’ve not found explicitly stated anywhere else: that  
config variable inheritance is an all or nothing mechanism. Have I  
missed some docs somewhere?

Following on from this, I’d like to understand if there’s anything I  
can reliably determine from a variable’s name about the impact that  
defining it will have on _other_ variables inheritance.

Can I, for instance, assume that defining an xyx\_ prefixed variable in  
a sub-scope will affect _only_ the inheritance of other xyz\_ prefixed  
variables? Or can there be inheritance side-effects between, say $abc  
and $def that I can’t possibly determine without documentation or  
trial and error?

Equally, can I assume that _all_ xyz\_ prefixed variables will have  
their inheritance affected by the sub-scope definition of _any_ other  
xyz\_ prefixed variable? Or are there examples where defining $xyz\_foo  
does _not_ invalidate the inheritance of $xyz\_bar ?

## Thanks, Jonathan

Jonathan M.  
London, Oxford, UK  
[http://www.jpluscplusm.com/contact.html](http://www.jpluscplusm.com/contact.html)

---

<div class="post-metadata">

**Author:** ![jonathan2000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/fbc32d/32.png) [@jonathan2000](https://www.ruby-forum.com/u/jonathan2000)\
**Post date:** [April 3, 2012, 5:53pm UTC](https://www.ruby-forum.com/t/config-variable-inheritance-docs-and-rules/218531/2 "2012-04-03T17:53:01Z")

</div>

On Tue, Apr 03, 2012 at 02:13:57PM +0100, Jonathan M. wrote:

Hi there,

> [Problem with inheriting fastcgi params - NGINX - Ruby-Forum](http://www.ruby-forum.com/topic/188742) seems to contain some  
> information I’ve not found explicitly stated anywhere else: that  
> config variable inheritance is an all or nothing mechanism. Have I  
> missed some docs somewhere?

That thread refers to configuration directives, not variables.

The difference might not matter, but for clarity it’s worth making sure  
that we all understand the same thing.

In the above thread, the (wrong) expectation was that “fastcgi\_param”  
at one level would add to “fastcgi\_param” from an enclosing level. In  
fact, nginx doesn’t add between levels.

That is how nginx configuration works.

Each request is handled by exactly one location.

Only the configuration in that location, and inherited into that  
location,  
matters. Inheritance is global \> http \> server \> location.

If a directive is used in that location, it overrides any  
might-have-been-inherited values for that directive.

This is as true for single-valued directives like “root” as it is for  
multi-valued directives like “fastcgi\_param”.

Whether a particular directive can be inherited depends on the module  
that processes it – which means “depends on the documentation”. But if  
it _can_ be inherited, it should follow the above rules. (Or it’s a  
bug.)

The rest of your mail talks specifically about defining variables;  
I’m talking about directives. Someone else may be able to explain the  
variable rules; if you do mean “directives”, then the above should make  
it clear what the answer in each case is.

There are some subtleties about what exactly is “a request”; and what  
locations are involved when “if” is used; and how nested locations work.

But for trying to find what configuration applies to a particular  
incoming http request, the “inherit or replace, but never add” rule  
makes it straightforward to understand.

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jonathan2000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/fbc32d/32.png) [@jonathan2000](https://www.ruby-forum.com/u/jonathan2000)\
**Post date:** [April 3, 2012, 7:08pm UTC](https://www.ruby-forum.com/t/config-variable-inheritance-docs-and-rules/218531/3 "2012-04-03T19:08:04Z")

</div>

On 3 April 2012 16:52, Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The difference might not matter, but for clarity it’s worth making sure  
> that we all understand the same thing.

You’re absolutely correct; I’m referring to config directives, but was  
thinking too hard about the question to notice I’d mixed my  
terminologies. I’ll correct it, and resend the email in a new thread  
for list archive niceness. It’d be great if you could cherry pick the  
stuff you feel is relevant from your reply and resend it. If only for  
those who come after … 🙂

## Jonathan

Jonathan M.  
London, Oxford, UK

> **[Jonathan Matthews :: Words Typed, Great Rates For Cash](https://www.jpluscplusm.com)**
