Opened 16 months ago
Last modified 16 months ago
#2310 accepted defect
Document behaviour for all config statements in nested location blocks
|Reported by:||Owned by:|
|nginx -V:||The documentation on your website, presumably the latest version|
From my understanding each request is only ever handled in a single top level location block and some, but not all statements are inherited in nested location blocks. Each location may also only have exactly one block.
Ideally this could be changed to actually allow for modularity and reduced duplication of statements but since this system is unlikely to change for backwards compatibility reasons it would at least be useful to know which statements need to be duplicated in every nested location block and which are inherited.
I ran into this issue when some location blocks that were only meant to disable password protection for specific domains also disabled the reverse proxy for those locations. Presumably proxy_pass is what this post calls a command type directive
Change History (1)
comment:1 by , 16 months ago
|Status:||new → accepted|
Thanks for the ticket. In general, all nginx configuration directives are inherited from the previous levels (unless redefined at the current level). There are very few exceptions, notably:
set. The rewrite module directives behaviour is explicitly documented.
stub_status. These directives are only allowed at location level and weren't subject to inheritance at all till introduction of nested locations. This is probably not documented good enough, though the concept is quite obvious.
try_filesdirective. Not really sure this is how it should work though, and might be considered to be a bug (see ticket #86 and ticket #633).
ifin location (which is also a rewrite module directive).
Most of these exceptions are believed to be more or less obvious and intuitive, though it indeed might make sense to document all this more explicitly.