mirror of
https://github.com/apache/httpd.git
synced 2025-05-28 13:41:30 +03:00
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@421136 13f79535-47bb-0310-9956-ffa450edef68
466 lines
17 KiB
XML
466 lines
17 KiB
XML
<?xml version="1.0" encoding="EUC-KR" ?>
|
|
<!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
|
|
<?xml-stylesheet type="text/xsl" href="./style/manual.ko.xsl"?>
|
|
<!-- English Revision: 105989:420990 (outdated) -->
|
|
|
|
<!--
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
this work for additional information regarding copyright ownership.
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
(the "License"); you may not use this file except in compliance with
|
|
the License. You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
<manualpage metafile="sections.xml.meta">
|
|
|
|
<title>섹션 설정</title>
|
|
|
|
<summary> <p><a href="configuring.html">설정파일</a>에 있는
|
|
지시어는 서버 전체에 적용되거나, 특정 디렉토리, 파일, 호스트,
|
|
URL에만 적용될 수 있다. 이 문서는 다른 지시어의 적용범위를
|
|
제한하기위해 설정 섹션이나 <code>.htaccess</code> 파일을
|
|
사용하는 방법을 설명한다.</p>
|
|
</summary>
|
|
|
|
<section id="types"><title>설정 섹션의 종류</title>
|
|
|
|
<related>
|
|
<modulelist>
|
|
<module>core</module>
|
|
<module>mod_proxy</module>
|
|
</modulelist>
|
|
<directivelist>
|
|
<directive type="section" module="core">Directory</directive>
|
|
<directive type="section" module="core">DirectoryMatch</directive>
|
|
<directive type="section" module="core">Files</directive>
|
|
<directive type="section" module="core">FilesMatch</directive>
|
|
<directive type="section" module="core">IfDefine</directive>
|
|
<directive type="section" module="core">IfModule</directive>
|
|
<directive type="section" module="core">Location</directive>
|
|
<directive type="section" module="core">LocationMatch</directive>
|
|
<directive type="section" module="mod_proxy">Proxy</directive>
|
|
<directive type="section" module="mod_proxy">ProxyMatch</directive>
|
|
<directive type="section" module="core">VirtualHost</directive>
|
|
</directivelist>
|
|
</related>
|
|
|
|
<p>섹션에는 두가지 종류가 있다. 대부분은 매요청마다 처리된다.
|
|
해당하는 요청에만 안에 포함한 지시어를 적용한다. 반대로, <directive
|
|
type="section" module="core">IfDefine</directive>과 <directive
|
|
type="section" module="core">IfModule</directive>은 서버가
|
|
시작할때와 꺼질때만 처리한다. 시작할때 상태가 참이면 안에 있는
|
|
지시어가 모든 요청에 적용된다. 참이 아니면 안에 있는 지시어는
|
|
무시한다.</p>
|
|
|
|
<p><directive type="section" module="core">IfDefine</directive>
|
|
지시어는 <code>httpd</code> 명령행에 적절한 파라미터가 있는
|
|
경우에만 안에 포함한 지시어를 적용한다. 다음 설정을 예로 들면,
|
|
서버를 <code>httpd -DClosedForNow</code>로 시작할 경우에만
|
|
모든 요청이 다른 사이트로 리다이렉션된다:</p>
|
|
|
|
<example>
|
|
<IfDefine ClosedForNow><br />
|
|
Redirect / http://otherserver.example.com/<br />
|
|
</IfDefine>
|
|
</example>
|
|
|
|
<p><directive type="section" module="core">IfModule</directive>
|
|
지시어도 특정 모듈이 서버에 포함된 경우에만 안에 든 지시어를
|
|
적용한다는 점을 제외하고는 매우 비슷하다. 모듈을 서버에 정적으로
|
|
컴파일하거나 동적으로 컴파일한후 설정파일 앞에 <directive
|
|
module="mod_so">LoadModule</directive> 줄이 있어야 한다. 이
|
|
지시어는 특정 모듈의 설치유무에 따라 설정파일이 다를 필요가
|
|
있을때만 사용해야 한다. 모듈이 없는 경우 유용한 오류문이 나오지않을
|
|
수 있기 때문에 언제나 사용하길 원하는 지시어를 안에 두면 안된다.</p>
|
|
|
|
<p>다음 예에서 <module>mod_mime_magic</module>이 있을때만 <directive
|
|
module="mod_mime_magic">MimeMagicFiles</directive> 지시어를
|
|
처리한다.</p>
|
|
|
|
<example>
|
|
<IfModule mod_mime_magic.c><br />
|
|
MimeMagicFile conf/magic<br />
|
|
</IfModule>
|
|
</example>
|
|
|
|
<p><directive type="section" module="core">IfDefine</directive>과
|
|
<directive type="section" module="core">IfModule</directive>의
|
|
검사 앞에 "!"을 붙여 조건을 역으로 할 수 있다. 또, 여러 섹션들을
|
|
겹쳐서 사용하여 더 복잡한 효과를 얻을 수 있다.</p>
|
|
</section>
|
|
|
|
<section id="file-and-web"><title>파일시스템과 웹공간</title>
|
|
|
|
<p>가장 자주 사용되는 설정 섹션은 파일시스템과 웹공간(webspace)의
|
|
특정 장소에 대한 설정을 변경하는 것들이다. 먼저 이 둘의 차이를
|
|
이해하는 것이 중요하다. 파일시스템은 운영체제 입장에서 디스크를
|
|
보는 관점이다. 예를 들어, 기본값으로 아파치를 설치를 하면 유닉스
|
|
파일시스템의 경우 <code>/usr/local/apache2</code>, 윈도우즈
|
|
파일시스템의 경우 <code>"c:/Program Files/Apache
|
|
Group/Apache2"</code>에 설치된다. (아파치는 윈도우즈에서 조차
|
|
항상, 역슬래쉬가 아닌, 슬래쉬를 사용함을 주의하라.) 반대로
|
|
웹공간은 웹서버가 제공하고 클라이언트가 보게될 사이트의 관점이다.
|
|
그래서 유닉스에서 기본 아파치 설치를 한 경우 웹경로의 경로
|
|
<code>/dir/</code>은 파일시스템 경로
|
|
<code>/usr/local/apache2/htdocs/dir/</code>에 해당한다. 웹공간은
|
|
데이타베이스 등에서 동적으로 생성될 수 있기때문에 반드시
|
|
파일시스템에 직접 대응될 필요는 없다.</p>
|
|
|
|
<section id="filesystem"><title>파일시스템 섹션</title>
|
|
|
|
<p><directive type="section" module="core">Directory</directive>와
|
|
<directive type="section" module="core">Files</directive> 지시어와
|
|
정규표현식을 사용하는 지시어는 파일시스템의 특정 부분에 지시어를
|
|
적용한다. <directive type="section"
|
|
module="core">Directory</directive> 지시어에 포함된 지시어들은
|
|
지정한 파일시스템 디렉토리와 그 하위 디렉토리에 적용된다. <a
|
|
href="howto/htaccess.html">.htaccess 파일</a>을 사용해도 결과는
|
|
같다. 다음 설정을 예로 들면, 디렉토리 목록(index)이
|
|
<code>/var/web/dir1</code> 이하 디렉토리에서 디렉토리 목록(index)이
|
|
가능하다.</p>
|
|
|
|
<example>
|
|
<Directory /var/web/dir1><br />
|
|
Options +Indexes<br />
|
|
</Directory>
|
|
</example>
|
|
|
|
<p><directive type="section"
|
|
module="core">Files</directive> 섹션에 포함된 지시어들은 어떤
|
|
디렉토리에 있는지 관계없이 지정한 이름을 가진 파일에 적용된다.
|
|
설정파일의 주설정부분에 있는 다음 설정을 예로 들면, 장소와
|
|
관계없이 <code>private.html</code>이란 이름을 한 파일의 접근을
|
|
거부한다.</p>
|
|
|
|
<example>
|
|
<Files private.html><br />
|
|
Order allow,deny<br />
|
|
Deny from all<br />
|
|
</Files>
|
|
</example>
|
|
|
|
<p>파일시스템의 특정 부분에 있는 파일을 지칭하기위해 <directive
|
|
type="section" module="core">Files</directive>와 <directive
|
|
type="section" module="core">Directory</directive> 섹션을 같이
|
|
사용한다. 다음 설정을 예로 들면,
|
|
<code>/var/web/dir1/private.html</code>,
|
|
<code>/var/web/dir1/subdir2/private.html</code>,
|
|
<code>/var/web/dir1/subdir3/private.html</code> 같이
|
|
<code>/var/web/dir1/</code> 디렉토리 아래에 있는 이름이
|
|
<code>private.html</code>인 파일의 접근을 거부한다.</p>
|
|
|
|
<example>
|
|
<Directory /var/web/dir1><br />
|
|
<Files private.html><br />
|
|
Order allow,deny<br />
|
|
Deny from all<br />
|
|
</Files><br />
|
|
</Directory>
|
|
</example>
|
|
</section>
|
|
|
|
<section id="webspace"><title>웹공간 섹션</title>
|
|
|
|
<p><directive type="section" module="core">Location</directive>
|
|
지시어와 이에 해당하는 정규표현식을 사용하는 지시어는 반대로
|
|
특정 웹공간의 설정을 바꾼다. 다음 설정을 예로 들면, /private으로
|
|
시작하는 URL-경로의 접근이 거부된다. 여기에는
|
|
<code>http://yoursite.example.com/private</code>,
|
|
<code>http://yoursite.example.com/private123</code>,
|
|
<code>http://yoursite.example.com/private/dir/file.html</code>
|
|
같이 <code>/private</code> 문자열로 시작하는 요청이 해당된다.</p>
|
|
|
|
<example>
|
|
<Location /private><br />
|
|
Order Allow,Deny<br />
|
|
Deny from all<br />
|
|
</Location>
|
|
</example>
|
|
|
|
<p><directive type="section" module="core">Location</directive>
|
|
지시어는 파일시스템에 대응할 필요가 없다. 다음 예는 어떻게 특정
|
|
URL을 <module>mod_status</module>가 제공하는 아파치 내부 핸들러로
|
|
대응시키는지를 보여준다. 파일시스템에 <code>server-status</code>라는
|
|
파일은 필요없다.</p>
|
|
|
|
<example>
|
|
<Location /server-status><br />
|
|
SetHandler server-status<br />
|
|
</Location>
|
|
</example>
|
|
</section>
|
|
|
|
<section id="wildcards"><title>와일드카드와 정규표현식</title>
|
|
|
|
<p><directive type="section" module="core">Directory</directive>,
|
|
<directive type="section" module="core">Files</directive>,
|
|
<directive type="section" module="core">Location</directive>
|
|
지시어에서 C 표준 파이브러리의 <code>fnmatch</code>와 같은
|
|
쉘에서 사용하는 와일드카드 문자를 사용할 수 있다.
|
|
"*" 문자는 어떤 문자열이라도 나타내고, "?" 문자는 어떤 문자 한개를
|
|
나타내며, "[<em>seq</em>]"는 <em>seq</em> 중에 한 문자를 나타낸다.
|
|
어떤 와일드카드도 "/" 문자를 나타내지는 못한다. 그래서 이 문자는
|
|
직접 사용해야 한다.</p>
|
|
|
|
<p>더 유연한 설정이 필요하면 perl호환 <a
|
|
href="glossary.html#regex">정규표현식</a>을 사용하는 <directive
|
|
type="section" module="core">DirectoryMatch</directive>, <directive
|
|
type="section" module="core">FilesMatch</directive>, <directive
|
|
type="section" module="core">LocationMatch</directive>를 사용할
|
|
수 있다. 그러나 아래 설정의 결합에 관한 절에서 정규표현식 섹션을
|
|
사용하면 지시어가 적용되는 방법이 어떻게 변하는지 살펴봐라.</p>
|
|
|
|
<p>모든 사용자 디렉토리 설정을 변경하는 비정규표현식 와일드카드
|
|
섹션은 다음과 같다:</p>
|
|
|
|
<example>
|
|
<Directory /home/*/public_html><br />
|
|
Options Indexes<br />
|
|
</Directory>
|
|
</example>
|
|
|
|
<p>정규표현식 섹션을 사용하여 한번에 여러 종류의 그림파일에
|
|
대한 접근을 거부할 수 있다:</p>
|
|
<example>
|
|
<FilesMatch \.(?i:gif|jpe?g|png)$><br />
|
|
Order allow,deny<br />
|
|
Deny from all<br />
|
|
</FilesMatch>
|
|
</example>
|
|
|
|
</section>
|
|
|
|
<section id="whichwhen"><title>무엇을 사용하나</title>
|
|
|
|
<p>파일시스템 섹션과 웹공간 섹션 중 하나를 선택하는 것은 실제로
|
|
매우 쉽다. 파일시스템에 있는 객체에 지시어를 적용할때는 항상
|
|
<directive type="section" module="core">Directory</directive>나
|
|
<directive type="section" module="core">Files</directive>를
|
|
사용한다. (데이타베이스에서 생성한 웹페이지와 같이) 파일시스템에
|
|
있지 않는 객체에 지시어를 적용할때는 <directive type="section"
|
|
module="core">Location</directive>을 사용한다.</p>
|
|
|
|
<p>파일시스템에 있는 객체의 접근을 제한하기위해 <directive
|
|
type="section" module="core">Location</directive>을 사용하면
|
|
절대 안된다. 여러 다른 웹공간 장소(URL)가 같은 파일시스템 장소에
|
|
대응될 수 있으므로, 걸어둔 제한을 우회할 수 있기 때문이다. 다음
|
|
설정의 예를 살펴보자:</p>
|
|
|
|
<example>
|
|
<Location /dir/><br />
|
|
Order allow,deny<br />
|
|
Deny from all<br />
|
|
</Location>
|
|
</example>
|
|
|
|
<p>이 설정은 <code>http://yoursite.example.com/dir/</code>을
|
|
요청한다면 잘 작동한다. 그러나 대소문자를 구별하지않는 파일시스템을
|
|
사용한다면 어떻게되나?
|
|
<code>http://yoursite.example.com/DIR/</code>을 요청하여 쉽게
|
|
제한을 우회할 수 있다. 반대로 <directive type="section"
|
|
module="core">Directory</directive> 지시어는 어떻게 요청하였는지
|
|
관계없이 그 장소에서 서비스되는 내용에 적용된다. (예외는 파일시스템
|
|
링크를 사용하는 경우다. 심볼링크를 사용하여 한 디렉토리를
|
|
파일시스템의 여러 장소에 둘 수 있다. <directive type="section"
|
|
module="core">Directory</directive> 지시어는 심볼링크를 따라간다.
|
|
그러므로 높은 수준의 보안을 위해서는 적절한 <directive
|
|
module="core">Options</directive> 지시어를 사용하여 심볼링크를
|
|
무시해야 한다.)</p>
|
|
|
|
<p>아마도 당신은 대소문자를 구별하는 파일시스템을 사용하므로
|
|
이런 일이 일어나지 않는다고 생각할지도 모른다. 그러나 다른
|
|
방법으로도 여러 웹공간 위치가 한 파일시스템 위치에 대응될 수
|
|
있음을 기억하라. 그래서 가능하면 항상 파일시스템 섹션을 사용해야
|
|
한다. 그러나 이 규칙에 예외가 하나 있다. 설정 제한을
|
|
<code><Location /></code> 섹션에 두면 이 섹션이 특정
|
|
URL이 아닌 모든 요청에 적용되므로 완벽하게 안전하다.</p>
|
|
</section>
|
|
|
|
</section>
|
|
|
|
<section id="virtualhost"><title>가상호스트</title>
|
|
|
|
<p><directive type="section" module="core">VirtualHost</directive>
|
|
섹션은 특정 호스트에 적용되는 지시어들을 포함한다. 이는 한
|
|
컴퓨터에서 각각 다른 설정을 사용한 여러 호스트를 서비스할때
|
|
유용하다. 더 자세한 정보는 <a href="vhosts/">가상호스트 문서</a>를
|
|
참고하라.</p>
|
|
</section>
|
|
|
|
<section id="proxy"><title>프록시</title>
|
|
|
|
<p><directive type="section" module="mod_proxy">Proxy</directive>와
|
|
<directive type="section" module="mod_proxy">ProxyMatch</directive>
|
|
섹션은 지정한 URL에 대해 <module>mod_proxy</module> 프록시 서버를
|
|
거쳐 접근하는 경우에만 적용된다. 다음 설정을 예로 들면, 프록시
|
|
서버를 통해 <code>cnn.com</code> 웹사이트에 접근할 수 없다.</p>
|
|
|
|
<example>
|
|
<Proxy http://cnn.com/*><br />
|
|
Order allow,deny<br />
|
|
Deny from all<br />
|
|
</Proxy>
|
|
</example>
|
|
</section>
|
|
|
|
<section id="whatwhere"><title>안에 어떤 지시어를 사용할 수
|
|
있나?</title>
|
|
|
|
<p>어떤 설정 섹션안에 사용할 수 있는 지시어를 알려면 지시어의
|
|
<a href="mod/directive-dict.html#Context">사용장소</a>를 확인하라.
|
|
<directive type="section" module="core">Directory</directive>에서
|
|
사용가능한 지시어는 <directive type="section"
|
|
module="core">DirectoryMatch</directive>, <directive type="section"
|
|
module="core">Files</directive>, <directive type="section"
|
|
module="core">FilesMatch</directive>, <directive type="section"
|
|
module="core">Location</directive>, <directive type="section"
|
|
module="core">LocationMatch</directive>, <directive type="section"
|
|
module="mod_proxy">Proxy</directive>, <directive type="section"
|
|
module="mod_proxy">ProxyMatch</directive> 섹션에서도 사용가능하다.
|
|
그러나, 예외가 있다:</p>
|
|
|
|
<ul>
|
|
<li><directive module="core">AllowOverride</directive> 지시어는
|
|
<directive type="section" module="core">Directory</directive>
|
|
섹션에서만 사용할 수 있다.</li>
|
|
|
|
<li><code>FollowSymLinks</code>, <code>SymLinksIfOwnerMatch</code>,
|
|
<directive module="core">Options</directive>는 <directive
|
|
type="section" module="core">Directory</directive> 섹션이나
|
|
<code>.htaccess</code> 파일에서만 사용할 수 있다.</li>
|
|
|
|
<li><directive module="core">Options</directive> 지시어는
|
|
<directive type="section" module="core">Files</directive>과
|
|
<directive type="section" module="core">FilesMatch</directive>
|
|
섹션에서 사용할 수 없다.</li>
|
|
</ul>
|
|
</section>
|
|
|
|
<section id="mergin"><title>섹션들이 결합하는 방법</title>
|
|
|
|
<p>설정 섹션은 매우 특별한 방법으로 적용된다. 이 순서가 설정
|
|
지시어를 해석하는 방법에 중요한 영향을 주기때문에 이 방법을
|
|
이해하는 것이 중요하다.</p>
|
|
|
|
<p>결합하는 순서는:</p>
|
|
|
|
<ol>
|
|
<li> (정규표현식을 사용하지않는) <directive type="section"
|
|
module="core">Directory</directive>와 <code>.htaccess</code>는
|
|
동시에 일어난다 (경우에 따라 <code>.htaccess</code>이
|
|
<directive type="section" module="core">Directory</directive>를
|
|
무시하도록 설정할 수 있다)</li>
|
|
|
|
<li><directive type="section"
|
|
module="core">DirectoryMatch</directive> (그리고
|
|
<code><Directory ~></code>)</li>
|
|
|
|
<li><directive type="section"
|
|
module="core">Files</directive>와 <directive type="section"
|
|
module="core">FilesMatch</directive>는 동시에 일어난다</li>
|
|
|
|
<li><directive type="section"
|
|
module="core">Location</directive>과 <directive type="section"
|
|
module="core">LocationMatch</directive>는 동시에 일어난다</li>
|
|
</ol>
|
|
|
|
<p><directive type="section"
|
|
module="core">Directory</directive>를 제외하고 각 섹션들을
|
|
설정파일에 나온 순서대로 처리된다. (위의 순서 1) <directive
|
|
type="section" module="core">Directory</directive>는 디렉토리
|
|
내용이 가장 짧은 것에서 긴쪽으로 처리된다. 그래서 예를 들어,
|
|
<code><Directory /var/web/dir></code>을
|
|
<code><Directory /var/web/dir/subdir></code> 이전에
|
|
처리한다. 같은 디렉토리를 지칭하는 여러 <directive
|
|
type="section" module="core">Directory</directive> 섹션이
|
|
있다면 이들을 설정파일 순서대로 처리한다. <directive
|
|
module="core">Include</directive> 지시어로 포함한 설정은
|
|
<directive module="core">Include</directive> 지시어 위치에
|
|
포함한 파일 내용이 있는 것처럼 처리한다.</p>
|
|
|
|
<p><directive type="section"
|
|
module="core">VirtualHost</directive> 섹션 안에 포함된 섹션은
|
|
가상호스트 정의 밖에 있는 해당 섹션 <em>이후에</em> 적용된다.
|
|
그래서 가상호스트 안에서 주서버의 설정사항을 수정할 수 있다.</p>
|
|
|
|
<p><module>mod_proxy</module>가 요청 서비스할때, <directive
|
|
module="mod_proxy" type="section">Proxy</directive> 섹션의
|
|
처리순서는 <directive module="core"
|
|
type="section">Directory</directive> 섹션과 같다.</p>
|
|
|
|
<p>다음에 나오는 섹션은 이전 섹션의 결과를 수정한다.</p>
|
|
|
|
<note><title>기술적 주의</title>
|
|
실제로
|
|
<code><Location></code>/<code><LocationMatch></code>는
|
|
(<code>Aliases</code>와 <code>DocumentRoot</code>를 사용하여
|
|
URL을 파일명으로 변환하는) 이름번역 단계 이전에 처리된다.
|
|
변역이 끝난 이후에는 완전히 무시한다.
|
|
</note>
|
|
|
|
<section id="merge-examples"><title>예제</title>
|
|
|
|
<p>다음은 겹합하는 순서를 설명하는 예다. 이들 모두 요청에
|
|
적용된다고 가정하면 지시어는 A > B > C > D > E
|
|
순서로 처리된다.</p>
|
|
|
|
<example>
|
|
<Location /><br />
|
|
E<br />
|
|
</Location><br />
|
|
<br />
|
|
<Files f.html><br />
|
|
D<br />
|
|
</Files><br />
|
|
<br />
|
|
<VirtualHost *><br />
|
|
<Directory /a/b><br />
|
|
B<br />
|
|
</Directory><br />
|
|
</VirtualHost><br />
|
|
<br />
|
|
<DirectoryMatch "^.*b$"><br />
|
|
C<br />
|
|
</DirectoryMatch><br />
|
|
<br />
|
|
<Directory /a/b><br />
|
|
A<br />
|
|
</Directory><br />
|
|
<br />
|
|
</example>
|
|
|
|
<p>더 현실적인 예는 다음과 같다. <directive module="core"
|
|
type="section">Location</directive> 섹션을 나중에 처리하므로
|
|
<directive module="core" type="section">Directory</directive>
|
|
섹션에 있는 접근제한과 관계없이 서버에 무제한 접근을 가능하다.
|
|
즉, 결합하는 순서는 중요하므로 주의하라!</p>
|
|
|
|
<example>
|
|
<Location /><br />
|
|
Order deny,allow<br />
|
|
Allow from all<br />
|
|
</Location><br />
|
|
<br />
|
|
# 악! 이 <Directory> 섹션은 아무런 효과가 없다<br />
|
|
<Directory /><br />
|
|
Order allow,deny<br />
|
|
Allow from all<br />
|
|
Deny from badguy.example.com<br />
|
|
</Directory>
|
|
</example>
|
|
|
|
</section>
|
|
|
|
</section>
|
|
</manualpage>
|
|
|