Bug 60479 - Add some details about <Location> and ProxyPass
Summary: Add some details about <Location> and ProxyPass
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Documentation (show other bugs)
Version: 2.4.23
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: HTTP Server Documentation List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-14 16:39 UTC by khemir.med
Modified: 2016-12-14 17:11 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description khemir.med 2016-12-14 16:39:41 UTC
Hi,

During some tests, we saw a change between 2.2.31 and 2.4.23 on how the ProxyPass directives are processed when they are in a <Location> directive.

For example, taking this configuration: 
<Location /foo>                                                                                                                                                                         
  ProxyPass         http://backend2/                                                                                                                                                    
  ProxyPassReverse  http://backend2/                                                                                                                                                    
</Location>                                                                                                                                                                             
<Location />                                                                                                                                                                            
  ProxyPass        http://backend1/                                                                                                                                                     
  ProxyPassReverse http://backend1/                                                                                                                                                     
</Location>   

In 2.2, when accessing to http://example.com/foo, we reach http://backend2/.
In 2.4, when accessing the same url, we reach http://backend1/.

This change in behaviour does not appear to be documented in the 2.2 -> 2.4 upgrade docs.
(Very carefully) comparing the documentation for ProxyPass between 2.2 and 2.4 shows the addition of a easily-missed but important line in 2.4 near the end of the "Ordering ProxyPass Directives" bit about the interaction with <Location> that reads:

"In contrast, only one ProxyPass directive can be placed in a Location block, and the most specific location will take precedence."

Since /foo is a more specific location than /, this suggests that either order of the <Location> sections in the example should result in /foo being forwarded to backend2, but this is not the case.

After some more reflection on the issue, I realized that perhaps "most specific location" should instead be interpreted as "the last <Location> section that matched the request URI".
Indeed, as per the merging rules outlined in the "How the sections are merged" documentation, <Location> blocks should generally be ordered in order from more general appearing first, followed by more specific overrides for sub-URIs.

In that sense, both meanings of "most specific location" align.
However, this is not immediately clear to people with ProxyPass-inside-Location configs coming from 2.2, where the <Location> blocks had to be flipped around due to the behaviour of ProxyPass in 2.2.

So presumably the extra line in the "Ordering ProxyPass directives" block is referring to the fact that the discrepancy of the order in which ProxyPasses inside <Location>s are matched in 2.2 has now been fixed in 2.4, but then I submit that:
  - the wording "most specific location" is ambiguous and not necessarily clear to people coming from 2.2
  - this should perhaps get a mention in the 2.2 -> 2.4 upgrade docs

Thank you.

Kind regards,

M. Khemir