병합 순서는 상당히 복잡하며 예외로 쉽게 포착 할 수 있습니다 ... 아파치 문서는 " 섹션 병합 방법 "입니다.
해당 문서에 따르면 섹션 병합 순서는 각 일치 유형에 대해 일치하는 항목을 모두 구성 파일에서 발견 된 순서대로 처리 한 다음 <Directory를 제외하고 다음 유형으로 이동하여 수행됩니다. >, 경로 별 순서대로 처리됩니다).
유형의 순서는 Directory, DirectoryMatch, Files, 그리고 마지막으로 Location. 나중에 일치하면 이전 일치를 덮어 씁니다. (* ProxyPass와 Alias는 다시 다르게 취급됩니다.
<Location> 섹션의 ProxyPass 및 ProxyPass 사용에 적용되는 이러한 규칙에는 몇 가지 중요한 예외가 있습니다. (아래 참조)
따라서 위의 예제 에서 다음 구성을 사용하여 http://somehost.com/sub/foobar 를 요청 하십시오 .
<Location / >
ProxyPass http://backend.com/
Order allow,deny
Satisfy any
</Location>
<Location /sub/foo>
Order allow,deny
</Location>
<Location /sub >
Order deny,allow
Require valid-user
Satisfy all
</Location>
<Location /doesnt/match >
ProxyPass !
</Location>
다음 지시문을 축적합니다 ....
ProxyPass http://backend.com/
Order allow,deny
Satisfy any
Order allow,deny
Order deny,allow
Require valid-user
Satisfy all
나중에 일치하면 이전 중복이 제거되어 결과가 나타납니다.
ProxyPass http://backend.com/
Order deny,allow
Require valid-user
Satisfy all
설명은
나중에를 제외하고 이전 경기 덮어 쓰기 일치 <Directory>긴으로 짧은 디렉토리 구성 요소 : 경기가 순서대로 처리됩니다 어디에.
예를 들어,
지시어가 구성에 지정된 순서에 관계없이
<Directory /var/web/dir>
이전에 처리
<Directory /var/web/dir/subdir>
되며보다 구체적인 일치가 승리합니다.
일치하는 Location지시문은 항상 이전에 일치하는 Directory지시문 보다 우선합니다 .
기본적인 아이디어는 같은 요청이다 GET /some/http/request.html내부적가 통해 파일 시스템 내의 위치로 변환한다 Alias, ScriptAlias또는 아래의 일반 파일 위치 DocumentRootVirtualHost의 것이 일치하는 것이다.
따라서 요청에는 일치하는 데 사용되는 다음과 같은 속성이 있습니다.
Location: /some/http/request.html
File: /var/www/html/mysite/some/http/request.html
Directory: /var/www/html/mysite/some/http
그런 다음 Apache는 Directory구성에서 디렉토리 특정 순서 로 모든 일치 항목을 차례로 적용한 다음 apply DirectoryMatch,, Files마지막으로 Location일치하는 순서대로 일치시킵니다.
따라서 Location우선 순위가 가장 낮은 경로와 일치하는 을 ( Files를) 재정의 합니다. 따라서 위의 예 에서 처음 3 개 위치를 순서대로 요청하면 충돌 지시문에서 마지막 위치가 우선합니다.DirectoryMatchDirectory/sub/foobar
(당신은 어떤 것을, 그것의 가능한 가장자리의 경우 일부 해결 방법 문서에서 명확하지 않은 경우 옳다 allow from *타입의 지시가 관련에 연결된다 Order allow,deny.하지만, 나는 그것을 테스트하지 않았다 당신이 일치하는 경우 또한 무슨 일이 Satisfy Any당신에게 있지만, 이전에 수집했습니다 Allow from *...)
ProxyPass와 Alias에 대한 흥미로운 메모
단지 성가신 것으로, ProxyPass그리고 Alias다른 방향으로 작업에 나타납니다이 ... ;-) 그것은 기본적으로 첫 경기 안타, 다음 중지 및 사용!
Ordering ProxyPass Directives
The configured ProxyPass and ProxyPassMatch rules are
checked in the order of configuration.
The first rule that matches wins. So
usually you should sort conflicting ProxyPass rules starting with the
longest URLs first. Otherwise later rules for longer URLS will be
hidden by any earlier rule which uses a leading substring of the URL.
Note that there is some relation with worker sharing.
For the same reasons exclusions must come before the general
ProxyPass directives.
따라서 기본적으로 Alias 및 ProxyPass 지시어가 가장 구체적으로 지정되어야합니다.
Alias "/foo/bar" "/srv/www/uncommon/bar"
Alias "/foo" "/srv/www/common/foo"
과
ProxyPass "/special-area" "http://special.example.com" smax=5 max=10
ProxyPass "/" "balancer://mycluster/" stickysession=JSESSIONID|jsessionid nofailover=On
그러나 @orev가 지적했듯이. Location 지시문에 ProxyPass 지시문을 사용할 수 있으므로 Location의보다 구체적인 ProxyPass가 이전에 찾은 ProxyPass를 능가합니다.