developer/ 40755 0 0 0 11237400230 10065 5ustar 0 0 faq/ 40755 0 0 0 11237400230 6647 5ustar 0 0 howto/ 40755 0 0 0 11237400230 7240 5ustar 0 0 images/ 40755 0 0 0 11237400230 7345 5ustar 0 0 misc/ 40755 0 0 0 11237400230 7033 5ustar 0 0 mod/ 40755 0 0 0 11237400231 6660 5ustar 0 0 platform/ 40755 0 0 0 11237400231 7725 5ustar 0 0 programs/ 40755 0 0 0 11237400231 7733 5ustar 0 0 rewrite/ 40755 0 0 0 11237400231 7562 5ustar 0 0 ssl/ 40755 0 0 0 11237400231 6702 5ustar 0 0 style/ 40755 0 0 0 11237400231 7241 5ustar 0 0 style/_generated/ 40755 0 0 0 11237400231 11336 5ustar 0 0 style/css/ 40755 0 0 0 11237377775 10063 5ustar 0 0 style/lang/ 40755 0 0 0 11237400231 10162 5ustar 0 0 style/latex/ 40755 0 0 0 11237400231 10356 5ustar 0 0 style/xsl/ 40755 0 0 0 11237400231 10047 5ustar 0 0 style/xsl/util/ 40755 0 0 0 11237400231 11024 5ustar 0 0 vhosts/ 40755 0 0 0 11237400231 7427 5ustar 0 0 bind.html100644 0 0 25104 11237400230 10021 0ustar 0 0 バインド - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2

バインド

This translation may be out of date. Check the English version for recent changes.

Apache が使用するアドレスとポートの設定をします。

参照

top

概要

Apache は起動時に、ローカルマシンのあるポートおよびアドレス に対して接続し、リクエストが来るのを待ちます。 デフォルトではマシンのすべてのアドレスに対して listen します。 しかしながら、特定のポートか、特定のアドレスのみか、 またはそれらの組み合わせのいずれかを listen するようにする必要があります。 これは、異なる IP アドレス、ホスト名、ポートに対する Apache の応答方法を決定するバーチャルホスト機能と組み合わせて使われます。

Listen ディレクティブで、特定のポートやアドレス・ポートの組からのみ入ってくる リクエストを受け付けるようにできます。 もしポート番号のみが Listen ディレクティブで指定された場合は、 すべてのインターフェースの与えられたポート番号を listen します。 IP アドレスがポート番号と同時に与えられた場合は、 サーバは与えられたポートとインターフェースを listen します。 複数の Listen ディレクティブを用いて いくつかの listen するアドレスとポートを指定できます。 サーバはリストされたアドレスやポートからのすべてのリクエストに 対して応答します。

たとえば、ポート 80 と 8000 の両方に対しての接続を受け付けるには

Listen 80
Listen 8000

とします。 二つの指定されたインタフェースとポート番号に対しての接続を受け付けるには、

Listen 192.0.2.1:80
Listen 192.0.2.5:8000

とします。 IPv6 アドレスは、角括弧で次の例のように囲まなければいけません。

Listen [2001:db8::a00:20ff:fea7:ccea]:80

top

IPv6 の特記事項

多くのプラットホームで IPv6 がサポートされてきていて、 APR はこれらのほとんどで IPv6 をサポートしているので、 Apache は IPv6 ソケットを割り当てて IPv6 経由で送られてきたリクエストを扱うことができます。

IPv6 ソケットが IPv4 と IPv6 コネクションの両方を扱うことができるか どうかは、Apache 管理者にとって厄介な問題です。 IPv4 コネクションを IPv6 ソケットで扱う場合は、 IPv4 マップされた IPv6 アドレスを使用していて、 ほとんどのプラットホームではデフォルトで使用可能ですが、 FreeBSD, NetBSD, OpenBSD では、システム全体としてのポリシーとの整合性から、 デフォルトでは使用不可に設定されています。 これらのデフォルトで使用不可のプラットホームであっても、 特別な configure の 設定パラメータで Apache の挙動を変化させることができます。

一方で、Linux や Tru64 といったプラットホームで IPv4 と IPv6 の両方を扱うには、マップトアドレスを使用する以外の方法はありません。 IPv4 と IPv6 のコネクションを最小限のソケットで扱いたいのであれば、 IPv4 マップの IPv6 アドレスを使用する必要があり、 --enable-v4-mapped configure オプションを指定します。

--enable-v4-mapped は、 FreeBSD, NetBSD, OpenBSD 以外の全てのプラットホームでのデフォルトです。 ですから、おそらくお手元の Apache はこの設定でビルドされているでしょう。

プラットフォームや APR が何をサポートするかに関わらず、 IPv4 コネクションのみを扱うようにしたい場合は、 次の例のように全ての Listen ディレクティブで IPv4 アドレスを指定してください。

Listen 0.0.0.0:80
Listen 192.0.2.1:80

条件を満たすプラットホームで、Apache が IPv4 と IPv6 のコネクションを個別のソケットで扱うようにしたい場合 (つまり IPv4 マップのアドレスを無効にしたい場合) は、--disable-v4-mapped configure オプションを指定して、次のように個別指定の Listen ディレクティブを使用してください。 --disable-v4-mapped は、 FreeBSD, NetBSD, OpenBSD プラットホームでのデフォルトです。

top

バーチャルホストに対してどう働くのか

Listen でバーチャルホストが実装されるわけではありません。 Listen は単にメインサーバにどのアドレスとポートを listen すべきかを 教えるだけです。 <VirtualHost> ディレクティブが使われない場合は、 受け入れたリクエストすべてに対して全く同じ挙動をします。 しかしながら <VirtualHost> を使って、 一つ以上のアドレスやポートに対して異なる挙動をするように 指定することができます。 VirtualHost を実装するには、使用するアドレスとポートを まず初めにサーバに通知しなければなりません。 そして、その指定したアドレスとポートでの このバーチャルホストの挙動を設定するために、 <VirtualHost> セクションを作ります。もし <VirtualHost> が listen していないアドレスとポートに対して 設定されてしまうと、 それにはアクセスできないということに注意してください。

caching.html100644 0 0 112040 11237400230 10515 0ustar 0 0 Caching Guide - Apache HTTP Server
<-
Apache > HTTP Server > Documentation > Version 2.2

Caching Guide

This document supplements the mod_cache, mod_disk_cache, mod_mem_cache, mod_file_cache and htcacheclean reference documentation. It describes how to use Apache's caching features to accelerate web and proxy serving, while avoiding common problems and misconfigurations.

top

Introduction

As of Apache HTTP server version 2.2 mod_cache and mod_file_cache are no longer marked experimental and are considered suitable for production use. These caching architectures provide a powerful means to accelerate HTTP handling, both as an origin webserver and as a proxy.

mod_cache and its provider modules mod_mem_cache and mod_disk_cache provide intelligent, HTTP-aware caching. The content itself is stored in the cache, and mod_cache aims to honour all of the various HTTP headers and options that control the cachability of content. It can handle both local and proxied content. mod_cache is aimed at both simple and complex caching configurations, where you are dealing with proxied content, dynamic local content or have a need to speed up access to local files which change with time.

mod_file_cache on the other hand presents a more basic, but sometimes useful, form of caching. Rather than maintain the complexity of actively ensuring the cachability of URLs, mod_file_cache offers file-handle and memory-mapping tricks to keep a cache of files as they were when Apache was last started. As such, mod_file_cache is aimed at improving the access time to local static files which do not change very often.

As mod_file_cache presents a relatively simple caching implementation, apart from the specific sections on CacheFile and MMapFile, the explanations in this guide cover the mod_cache caching architecture.

To get the most from this document, you should be familiar with the basics of HTTP, and have read the Users' Guides to Mapping URLs to the Filesystem and Content negotiation.

top

Caching Overview

There are two main stages in mod_cache that can occur in the lifetime of a request. First, mod_cache is a URL mapping module, which means that if a URL has been cached, and the cached version of that URL has not expired, the request will be served directly by mod_cache.

This means that any other stages that might ordinarily happen in the process of serving a request -- for example being handled by mod_proxy, or mod_rewrite -- won't happen. But then this is the point of caching content in the first place.

If the URL is not found within the cache, mod_cache will add a filter to the request handling. After Apache has located the content by the usual means, the filter will be run as the content is served. If the content is determined to be cacheable, the content will be saved to the cache for future serving.

If the URL is found within the cache, but also found to have expired, the filter is added anyway, but mod_cache will create a conditional request to the backend, to determine if the cached version is still current. If the cached version is still current, its meta-information will be updated and the request will be served from the cache. If the cached version is no longer current, the cached version will be deleted and the filter will save the updated content to the cache as it is served.

Improving Cache Hits

When caching locally generated content, ensuring that UseCanonicalName is set to On can dramatically improve the ratio of cache hits. This is because the hostname of the virtual-host serving the content forms a part of the cache key. With the setting set to On virtual-hosts with multiple server names or aliases will not produce differently cached entities, and instead content will be cached as per the canonical hostname.

Because caching is performed within the URL to filename translation phase, cached documents will only be served in response to URL requests. Ordinarily this is of little consequence, but there is one circumstance in which it matters: If you are using Server Side Includes;

<!-- The following include can be cached -->
<!--#include virtual="/footer.html" --> 

<!-- The following include can not be cached -->
<!--#include file="/path/to/footer.html" -->

If you are using Server Side Includes, and want the benefit of speedy serves from the cache, you should use virtual include types.

Expiry Periods

The default expiry period for cached entities is one hour, however this can be easily over-ridden by using the CacheDefaultExpire directive. This default is only used when the original source of the content does not specify an expire time or time of last modification.

If a response does not include an Expires header but does include a Last-Modified header, mod_cache can infer an expiry period based on the use of the CacheLastModifiedFactor directive.

For local content, mod_expires may be used to fine-tune the expiry period.

The maximum expiry period may also be controlled by using the CacheMaxExpire.

A Brief Guide to Conditional Requests

When content expires from the cache and is re-requested from the backend or content provider, rather than pass on the original request, Apache will use a conditional request instead.

HTTP offers a number of headers which allow a client, or cache to discern between different versions of the same content. For example if a resource was served with an "Etag:" header, it is possible to make a conditional request with an "If-None-Match:" header. If a resource was served with a "Last-Modified:" header it is possible to make a conditional request with an "If-Modified-Since:" header, and so on.

When such a conditional request is made, the response differs depending on whether the content matches the conditions. If a request is made with an "If-Modified-Since:" header, and the content has not been modified since the time indicated in the request then a terse "304 Not Modified" response is issued.

If the content has changed, then it is served as if the request were not conditional to begin with.

The benefits of conditional requests in relation to caching are twofold. Firstly, when making such a request to the backend, if the content from the backend matches the content in the store, this can be determined easily and without the overhead of transferring the entire resource.

Secondly, conditional requests are usually less strenuous on the backend. For static files, typically all that is involved is a call to stat() or similar system call, to see if the file has changed in size or modification time. As such, even if Apache is caching local content, even expired content may still be served faster from the cache if it has not changed. As long as reading from the cache store is faster than reading from the backend (e.g. an in-memory cache compared to reading from disk).

What Can be Cached?

As mentioned already, the two styles of caching in Apache work differently, mod_file_cache caching maintains file contents as they were when Apache was started. When a request is made for a file that is cached by this module, it is intercepted and the cached file is served.

mod_cache caching on the other hand is more complex. When serving a request, if it has not been cached previously, the caching module will determine if the content is cacheable. The conditions for determining cachability of a response are;

  1. Caching must be enabled for this URL. See the CacheEnable and CacheDisable directives.
  2. The response must have a HTTP status code of 200, 203, 300, 301 or 410.
  3. The request must be a HTTP GET request.
  4. If the request contains an "Authorization:" header, the response will not be cached.
  5. If the response contains an "Authorization:" header, it must also contain an "s-maxage", "must-revalidate" or "public" option in the "Cache-Control:" header.
  6. If the URL included a query string (e.g. from a HTML form GET method) it will not be cached unless the response includes an "Expires:" header, as per RFC2616 section 13.9.
  7. If the response has a status of 200 (OK), the response must also include at least one of the "Etag", "Last-Modified" or the "Expires" headers, unless the CacheIgnoreNoLastMod directive has been used to require otherwise.
  8. If the response includes the "private" option in a "Cache-Control:" header, it will not be stored unless the CacheStorePrivate has been used to require otherwise.
  9. Likewise, if the response includes the "no-store" option in a "Cache-Control:" header, it will not be stored unless the CacheStoreNoStore has been used.
  10. A response will not be stored if it includes a "Vary:" header containing the match-all "*".

What Should Not be Cached?

In short, any content which is highly time-sensitive, or which varies depending on the particulars of the request that are not covered by HTTP negotiation, should not be cached.

If you have dynamic content which changes depending on the IP address of the requester, or changes every 5 minutes, it should almost certainly not be cached.

If on the other hand, the content served differs depending on the values of various HTTP headers, it might be possible to cache it intelligently through the use of a "Vary" header.

Variable/Negotiated Content

If a response with a "Vary" header is received by mod_cache when requesting content by the backend it will attempt to handle it intelligently. If possible, mod_cache will detect the headers attributed in the "Vary" response in future requests and serve the correct cached response.

If for example, a response is received with a vary header such as;

Vary: negotiate,accept-language,accept-charset

mod_cache will only serve the cached content to requesters with accept-language and accept-charset headers matching those of the original request.

top

Security Considerations

Authorization and Access Control

Using mod_cache is very much like having a built in reverse-proxy. Requests will be served by the caching module unless it determines that the backend should be queried. When caching local resources, this drastically changes the security model of Apache.

As traversing a filesystem hierarchy to examine potential .htaccess files would be a very expensive operation, partially defeating the point of caching (to speed up requests), mod_cache makes no decision about whether a cached entity is authorised for serving. In other words; if mod_cache has cached some content, it will be served from the cache as long as that content has not expired.

If, for example, your configuration permits access to a resource by IP address you should ensure that this content is not cached. You can do this by using the CacheDisable directive, or mod_expires. Left unchecked, mod_cache - very much like a reverse proxy - would cache the content when served and then serve it to any client, on any IP address.

Local exploits

As requests to end-users can be served from the cache, the cache itself can become a target for those wishing to deface or interfere with content. It is important to bear in mind that the cache must at all times be writable by the user which Apache is running as. This is in stark contrast to the usually recommended situation of maintaining all content unwritable by the Apache user.

If the Apache user is compromised, for example through a flaw in a CGI process, it is possible that the cache may be targeted. When using mod_disk_cache, it is relatively easy to insert or modify a cached entity.

This presents a somewhat elevated risk in comparison to the other types of attack it is possible to make as the Apache user. If you are using mod_disk_cache you should bear this in mind - ensure you upgrade Apache when security upgrades are announced and run CGI processes as a non-Apache user using suEXEC if possible.

Cache Poisoning

When running Apache as a caching proxy server, there is also the potential for so-called cache poisoning. Cache Poisoning is a broad term for attacks in which an attacker causes the proxy server to retrieve incorrect (and usually undesirable) content from the backend.

For example if the DNS servers used by your system running Apache are vulnerable to DNS cache poisoning, an attacker may be able to control where Apache connects to when requesting content from the origin server. Another example is so-called HTTP request-smuggling attacks.

This document is not the correct place for an in-depth discussion of HTTP request smuggling (instead, try your favourite search engine) however it is important to be aware that it is possible to make a series of requests, and to exploit a vulnerability on an origin webserver such that the attacker can entirely control the content retrieved by the proxy.

top

File-Handle Caching

The act of opening a file can itself be a source of delay, particularly on network filesystems. By maintaining a cache of open file descriptors for commonly served files, Apache can avoid this delay. Currently Apache provides two different implementations of File-Handle Caching.

CacheFile

The most basic form of caching present in Apache is the file-handle caching provided by mod_file_cache. Rather than caching file-contents, this cache maintains a table of open file descriptors. Files to be cached in this manner are specified in the configuration file using the CacheFile directive.

The CacheFile directive instructs Apache to open the file when Apache is started and to re-use this file-handle for all subsequent access to this file.

CacheFile /usr/local/apache2/htdocs/index.html

If you intend to cache a large number of files in this manner, you must ensure that your operating system's limit for the number of open files is set appropriately.

Although using CacheFile does not cause the file-contents to be cached per-se, it does mean that if the file changes while Apache is running these changes will not be picked up. The file will be consistently served as it was when Apache was started.

If the file is removed while Apache is running, Apache will continue to maintain an open file descriptor and serve the file as it was when Apache was started. This usually also means that although the file will have been deleted, and not show up on the filesystem, extra free space will not be recovered until Apache is stopped and the file descriptor closed.

CacheEnable fd

mod_mem_cache also provides its own file-handle caching scheme, which can be enabled via the CacheEnable directive.

CacheEnable fd /

As with all of mod_cache this type of file-handle caching is intelligent, and handles will not be maintained beyond the expiry time of the cached content.

top

In-Memory Caching

Serving directly from system memory is universally the fastest method of serving content. Reading files from a disk controller or, even worse, from a remote network is orders of magnitude slower. Disk controllers usually involve physical processes, and network access is limited by your available bandwidth. Memory access on the other hand can take mere nano-seconds.

System memory isn't cheap though, byte for byte it's by far the most expensive type of storage and it's important to ensure that it is used efficiently. By caching files in memory you decrease the amount of memory available on the system. As we'll see, in the case of operating system caching, this is not so much of an issue, but when using Apache's own in-memory caching it is important to make sure that you do not allocate too much memory to a cache. Otherwise the system will be forced to swap out memory, which will likely degrade performance.

Operating System Caching

Almost all modern operating systems cache file-data in memory managed directly by the kernel. This is a powerful feature, and for the most part operating systems get it right. For example, on Linux, let's look at the difference in the time it takes to read a file for the first time and the second time;

colm@coroebus:~$ time cat testfile > /dev/null
real    0m0.065s
user    0m0.000s
sys     0m0.001s
colm@coroebus:~$ time cat testfile > /dev/null
real    0m0.003s
user    0m0.003s
sys     0m0.000s

Even for this small file, there is a huge difference in the amount of time it takes to read the file. This is because the kernel has cached the file contents in memory.

By ensuring there is "spare" memory on your system, you can ensure that more and more file-contents will be stored in this cache. This can be a very efficient means of in-memory caching, and involves no extra configuration of Apache at all.

Additionally, because the operating system knows when files are deleted or modified, it can automatically remove file contents from the cache when neccessary. This is a big advantage over Apache's in-memory caching which has no way of knowing when a file has changed.

Despite the performance and advantages of automatic operating system caching there are some circumstances in which in-memory caching may be better performed by Apache.

Firstly, an operating system can only cache files it knows about. If you are running Apache as a proxy server, the files you are caching are not locally stored but remotely served. If you still want the unbeatable speed of in-memory caching, Apache's own memory caching is needed.

MMapFile Caching

mod_file_cache provides the MMapFile directive, which allows you to have Apache map a static file's contents into memory at start time (using the mmap system call). Apache will use the in-memory contents for all subsequent accesses to this file.

MMapFile /usr/local/apache2/htdocs/index.html

As with the CacheFile directive, any changes in these files will not be picked up by Apache after it has started.

The MMapFile directive does not keep track of how much memory it allocates, so you must ensure not to over-use the directive. Each Apache child process will replicate this memory, so it is critically important to ensure that the files mapped are not so large as to cause the system to swap memory.

mod_mem_cache Caching

mod_mem_cache provides a HTTP-aware intelligent in-memory cache. It also uses heap memory directly, which means that even if MMap is not supported on your system, mod_mem_cache may still be able to perform caching.

Caching of this type is enabled via;

# Enable memory caching
CacheEnable mem /

# Limit the size of the cache to 1 Megabyte
MCacheSize 1024
top

Disk-based Caching

mod_disk_cache provides a disk-based caching mechanism for mod_cache. As with mod_mem_cache this cache is intelligent and content will be served from the cache only as long as it is considered valid.

Typically the module will be configured as so;

CacheRoot   /var/cache/apache/
CacheEnable disk /
CacheDirLevels 2
CacheDirLength 1

Importantly, as the cached files are locally stored, operating system in-memory caching will typically be applied to their access also. So although the files are stored on disk, if they are frequently accessed it is likely the operating system will ensure that they are actually served from memory.

Understanding the Cache-Store

To store items in the cache, mod_disk_cache creates a 22 character hash of the URL being requested. This hash incorporates the hostname, protocol, port, path and any CGI arguments to the URL, to ensure that multiple URLs do not collide.

Each character may be any one of 64-different characters, which mean that overall there are 64^22 possible hashes. For example, a URL might be hashed to xyTGxSMO2b68mBCykqkp1w. This hash is used as a prefix for the naming of the files specific to that URL within the cache, however first it is split up into directories as per the CacheDirLevels and CacheDirLength directives.

CacheDirLevels specifies how many levels of subdirectory there should be, and CacheDirLength specifies how many characters should be in each directory. With the example settings given above, the hash would be turned into a filename prefix as /var/cache/apache/x/y/TGxSMO2b68mBCykqkp1w.

The overall aim of this technique is to reduce the number of subdirectories or files that may be in a particular directory, as most file-systems slow down as this number increases. With setting of "1" for CacheDirLength there can at most be 64 subdirectories at any particular level. With a setting of 2 there can be 64 * 64 subdirectories, and so on. Unless you have a good reason not to, using a setting of "1" for CacheDirLength is recommended.

Setting CacheDirLevels depends on how many files you anticipate to store in the cache. With the setting of "2" used in the above example, a grand total of 4096 subdirectories can ultimately be created. With 1 million files cached, this works out at roughly 245 cached URLs per directory.

Each URL uses at least two files in the cache-store. Typically there is a ".header" file, which includes meta-information about the URL, such as when it is due to expire and a ".data" file which is a verbatim copy of the content to be served.

In the case of a content negotiated via the "Vary" header, a ".vary" directory will be created for the URL in question. This directory will have multiple ".data" files corresponding to the differently negotiated content.

Maintaining the Disk Cache

Although mod_disk_cache will remove cached content as it is expired, it does not maintain any information on the total size of the cache or how little free space may be left.

Instead, provided with Apache is the htcacheclean tool which, as the name suggests, allows you to clean the cache periodically. Determining how frequently to run htcacheclean and what target size to use for the cache is somewhat complex and trial and error may be needed to select optimal values.

htcacheclean has two modes of operation. It can be run as persistent daemon, or periodically from cron. htcacheclean can take up to an hour or more to process very large (tens of gigabytes) caches and if you are running it from cron it is recommended that you determine how long a typical run takes, to avoid running more than one instance at a time.


Figure 1: Typical cache growth / clean sequence.

Because mod_disk_cache does not itself pay attention to how much space is used you should ensure that htcacheclean is configured to leave enough "grow room" following a clean.

configuring.html100644 0 0 32116 11237400230 11420 0ustar 0 0 設定ファイル - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2

設定ファイル

この文書では、Apache HTTP サーバを設定するのに使用するファイルについて 記述しています。

top

メインの設定ファイル

Apache は ディレクティブ を設定ファイルに平文で書くことにより設定します。 メインの設定ファイルは普通は httpd.conf という名前です。 このファイルの位置はコンパイル時に設定されますが、コマンドラインの -f フラグにより上書きできます。 また、他の設定ファイルを Include ディレクティブによって追加でき、ワイルドカードを使用して多数の 設定ファイルを追加することができます。 どんなディレクティブも、これらの設定ファイルどれにでも入れることができます。 Apache は起動時か再起動時のみメイン設定ファイルの変更を認識します。

サーバは MIME ドキュメントタイプを含んでいるファイルも読み込みます。ファイル名は TypesConfig で設定され、デフォルトでは mime.types になっています。

top

設定ファイルの構文

Apache の設定ファイルは 1 行に 1 つのディレクティブからなります。 バックスラッシュ "\" はディレクティブが次の行に継続していることを 示すために行の最後の文字として使われているかもしれません。 行の最後とバックスラッシュの間に他の文字や空白があってはいけません。

設定ファイルのディレクティブは大文字小文字を区別しませんが、 引数にはしばしば区別するものがあります。ハッシュ文字 "#" で始まる行はコメントと見なされて無視されます。 設定ディレクティブの後の行ではコメントが含まれていてはいけません。ディレクティブの前の空行と空白は無視されますので、 わかりやすくするためにディレクティブをインデントしても構いません。

設定ファイルの構文エラーは、 apachectl configtest かコマンドラインオプション -t を使って調べられます。

top

モジュール

Apache はモジュール化されたサーバです。 コアサーバには最も基本的な機能だけが含まれています。拡張機能は Apache にロードされるモジュールとして利用可能です。デフォルトでは、コンパイル時にモジュールの Base セット (基本セット) が サーバに含まれます。サーバが動的ロードモジュールを使うようにコンパイルされている場合は、 モジュールを別にコンパイルして、いつでも LoadModule ディレクティブを使って追加できます。 そうでない場合は、モジュールの追加や削除をするためには Apache を再コンパイルする必要があります。設定ディレクティブは <IfModule> ブロックに入れることで特定のモジュールが存在するときだけ 設定ファイルに含まれるようにすることができます。

コマンドラインオプション -l を使って現時点で どのモジュールがサーバにコンパイルされているかを知ることができます。

top

ディレクティブの適用範囲

メイン設定ファイルにあるディレクティブはサーバ全体に適用されます。 サーバの一部分の設定だけを変更したい場合は <Directory>, <DirectoryMatch>, <Files>, <FilesMatch>, <Location>, <LocationMatch> セクションの中に置くことで適用範囲を決められます。 これらのセクションはその中にあるディレクティブの適用範囲を 特定のファイルシステムの位置や URL に限定します。 非常に細粒度の設定を可能にするために、 セクションを入れ子にすることもできます。

Apache は同時に多くの違うウェブサイトを扱う能力があります。 これは バーチャルホスト と呼ばれています。 特定のウェブサイトにのみ適用されるようにするために、 ディレクティブは <VirtualHost> セクションの中に置くことでも適用範囲を変えることができます。

ほとんどのディレクティブはどのセクションにでも書けますが、 中にはコンテキストによっては意味をなさないものもあります。 例えば、プロセスの作成を制御しているディレクティブはメインサーバの コンテキストにのみ書くことができます。 どのディレクティブをどのセクションに書くことができるかを知るためには ディレクティブの コンテキスト を調べてください。詳しい情報は、 Directory, Location, Files セクションの動作法にあります。

top

.htaccess ファイル

Apache ではウェブツリーの中に置かれた特別なファイルを使って 非中央集権的な設定管理をできます。その特別なファイルは普通は .htaccess という名前で、 AccessFileName ディレクティブでどんな名前にでも指定できます。 .htaccess ファイルに書かれたディレクティブはファイルを置いた ディレクトリとその全てのサブディレクトリに適用されます。 .htaccess ファイルは、メインの設定ファイルと同じ 構文を使います。 .htaccess ファイルはすべてのリクエストで読み込まれるため、 変更はすぐに反映されます。

どのディレクティブが .htaccess ファイルに書けるかを調べるには、ディレクティブのコンテキスト を調べてください。サーバ管理者はさらにメイン設定ファイルの AllowOverride を設定することでどのディレクティブを .htaccess ファイルに書けるようにするかを制御することができます。

.htaccess ファイルに関する詳しい情報は .htaccess チュートリアル を参照してください。

content-negotiation.html100644 0 0 112363 11237400230 13121 0ustar 0 0 コンテントネゴシエーション - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2

コンテントネゴシエーション

This translation may be out of date. Check the English version for recent changes.

Apache は HTTP/1.1 の規格に記述されているコンテントネゴシエーションを サポートしています。 ブラウザにより提供されたメディアタイプ、 言語、文字セット、エンコーディングの優先傾向に基づいて、 最適なリソースの表現を選択できます。 また、不完全なネゴシエーション情報を送ってくるブラウザからのリクエストを もっと賢く取り扱えるよう、いくつか機能も実装してあります。

コンテントネゴシエーションは mod_negotiation モジュールによって提供されていて、デフォルトで組み込まれています。

top

コンテントネゴシエーションについて

リソースは、幾つか異なった表現で利用できる場合があります。 例えば、異なる言語や異なるメディアタイプ、 またはそれらの組み合わせで利用できるかも知れません。 もっとも適した選択をする方法の一つには、インデックスページを ユーザに見せて、ユーザに選んでもらう方法があります。 しかし、サーバが自動的に選ぶことができる場合が多くあります。 これは、ブラウザがリクエスト毎に、 どの表現を嗜好するかという情報を送ることで動作しています。 例えばブラウザは、可能ならフランス語で情報を見たい、 不可能ならその代わりに英語でもよいと、 自分の嗜好を知らせることができます。 ブラウザはリクエストのヘッダで自分の優先傾向を知らせます。 フランス語のみの表現を要求する場合は、ブラウザは次を送ります。

Accept-Language: fr

この優先傾向は、選択可能な表現が存在して、 言語によって様々な表現がある場合にのみ適用される ということに注意してください。

もっと複雑なリクエストの例を挙げましょう。 このブラウザはフランス語と英語を受け付ける、しかしフランス語を好む、 そして様々なメディアタイプを受け付けるが、 プレインテキストや他のタイプよりは HTML を好む、 他のメディアタイプよりは GIF や JPEG を好む、しかし最終手段として 他のメディアタイプも受け付ける、と設定されています。

Accept-Language: fr; q=1.0, en; q=0.5
Accept: text/html; q=1.0, text/*; q=0.8, image/gif; q=0.6, image/jpeg; q=0.6, image/*; q=0.5, */*; q=0.1

Apache は HTTP/1.1 規格で定義されている 'server driven' コンテントネゴシエーションをサポートしています。 Accept, Accept-Language, Accept-Charset, Accept-Encoding リクエストヘッダを完全にサポートしています。Apache は 'transparent' コンテントネゴシエーションもサポートしていますが、 これは RFC 2295 と RFC 2296 で定義されている試験的な ネゴシエーションプロトコルです。 これらの RFCで定義されている 'feature negotiation' はサポートしていません。

リソースとは URI で特定される概念上のもののことです (RFC 2396)。 Apache のような HTTP サーバは、その名前空間の中での リソースの表現へのアクセスを提供します。 それぞれの表現は 定義されたメディアタイプ、文字セット、エンコーディング等の 付属した、バイト列の形式です。 それぞれのリソースはある時点で 0 個、1 個、それ以上の表現と 関連付けられる可能性があります。複数の表現が利用できる場合は、 リソースはネゴシエーション可能であるとされ、 個々の表現は variant と呼ばれます。 ネゴシエーション可能なリソースの variant が異なる、 その状態を指して、 ネゴシエーションの次元と呼びます。

top

Apache におけるネゴシエーション

リソースをネゴシエーションするためには、 サーバは variant それぞれについての情報を知っておく必要があります。 これは以下の二つの方法のどちらかで行われます。

type-map ファイルを使う

タイプマップは type-map ハンドラ (もしくは、古い Apache の設定と下位互換である MIME タイプ application/x-type-map) に関連付けられたドキュメントです。 この機能を使うためには、あるファイルの拡張子を type-map として定義するようなハンドラを、 設定ファイル中に置く必要があることに注意してください。 これは

AddHandler type-map .var

をサーバ設定ファイル中に書くことが一番良い方法です。

タイプマップファイルは記述するリソースと同じ名前を持っていて、 利用可能な variant それぞれのエントリを持っている必要があります。 そして、このエントリは連続した HTTP のヘッダ行で構成されます。 異なる variant のためのエントリは空行で区切られています。 エントリ中に空行が複数あってはいけません。 習慣的には、マップファイルは全体を結合したもののエントリから始まります (しかしこれは必須ではなく、あったとしても無視されるものです)。 次に例を示します。このファイルはリソース foo を記述しているので、foo.var という名前になります。

URI: foo

URI: foo.en.html
Content-type: text/html
Content-language: en

URI: foo.fr.de.html
Content-type: text/html;charset=iso-8859-2
Content-language: fr, de

たとえ MultiViews を使用するようになっていたとしても、 ファイル名の拡張子よりタイプマップの方が優先権を持つということにも 注意してください。 variant の品質が違うときは、この画像のように (JPEG, GIF, ASCII アートがあります) メディアタイプの "qs" パラメータで指定されます。

URI: foo

URI: foo.jpeg
Content-type: image/jpeg; qs=0.8

URI: foo.gif
Content-type: image/gif; qs=0.5

URI: foo.txt
Content-type: text/plain; qs=0.01

qs 値の範囲は 0.000 から 1.000 です。qs 値が 0.000 の variant は決して 選択されないことに注意してください。'qs' 値のない variant は qs 値 1.0 を 与えられます。qs パラメータはクライアントの能力に関係無く、他の variant と 比較したときの variant の相対的な「品質」を示します。 例えば、写真を表現しようとしているときは JPEG ファイルの方が普通は ASCII ファイルよりも高い品質になります。しかし、リソースが元々 ASCII アートで表現されているときは、ASCII ファイルの 方が JPEG ファイルよりも高い品質になります。このように、qs は 表現されるリソースの性質によって variant 毎に特有の値を取ります。

認識されるヘッダの一覧は mod_negotiation ドキュメントにあります。

Multiviews

MultiViews はディレクトリ毎のオプションで、 httpd.confファイルの <Directory>, <Location>, <Files> セクション中や、(AllowOverride が適切な値に 設定されていると) .htaccess ファイルで Options ディレクティブによって設定することができます。 Options AllMultiViews をセットしないことに注意してください。明示的に その名前を書く必要があります。

MultiViews の効果は以下のようになります: サーバが /some/dir/foo へのリクエストを受け取り、/some/dirMultiViews が有効であって、 /some/dir/foo が存在しない場合、 サーバはディレクトリを読んで foo.* にあてはまる全てのファイルを探し、 事実上それらのファイルをマップするタイプマップを作ります。 そのとき、メディアタイプとコンテントエンコーディングは、そのファイル名を 直接指定したときと同じものが割り当てられます。 それからクライアントの要求に一番合うものを選びます。

サーバがディレクトリの索引を作ろうとしている場合、 MultiViewsDirectoryIndex ディレクティブで指定されたファイルを探す過程にも 適用されます。設定ファイルに

DirectoryIndex index

が書かれていて、index.htmlindex.html3 が 両方存在していると、サーバはその中からどちらかを適当に選びます。 もしその両方が存在せずに index.cgi が存在していると、 サーバはそれを実行します。

もしディレクトリを読んでいる際に、 文字セット、コンテントタイプ、言語、エンコーディングを 指定するための mod_mime で認識できる拡張子を持たないファイルが見つかると、結果は MultiViewsMatch ディレクティブの設定に依存します。このディレクティブは ハンドラ、フィルタ、他のファイル拡張子タイプのどれが MultiViews ネゴシエーションで使用できるかを決定します。

top

ネゴシエーション方法

Apache はリソースの variant の一覧を、タイプマップファイルか ディレクトリ内のファイル名からかで取得した後、 「最適な」 variant を決定するために二つの方法の どちらかを起動します。 Apache のコンテントネゴシエーションの機能を使うために、 どのようにしてこの調停が行われるか詳細を知る必要はありません。 しかしながら、この文書の残りでは関心のある人のために、 使用されている方法について説明しています。

ネゴシエーション方法は二つあります。

  1. 通常は Apache のアルゴリズムを用いた Server driven negotiation が使用されます。Apache のアルゴリズムは後に詳細に説明されています。 このアルゴリズムが使用された場合、Apache はより良い結果になるように、特定の次元において品質の値を 「変える」ことができます。Apache が品質の値を変える方法は後で詳細に説明されています。
  2. RFC 2295 で定義されている機構を用いてブラウザが特に指定した場合、 transparent content negotiation が使用されます。このネゴシエーション方法では、「最適な」 variant の決定をブラウザが完全に制御することができます。 ですから、結果はブラウザが使用しているアルゴリズムに依存します。 Transparent negotiation の処理の過程で、ブラウザは RFC 2296 で 定義されている 'remote variant selection algorithm' を実行するように頼むことができます。

ネゴシエーションの次元

次元 説明
メディアタイプ ブラウザは Accept ヘッダフィールドで優先傾向を指定します。 アイテムそれぞれは、関連した品質数値を持つことができます。 variant の説明も品質数値を持つことができます ("qs" パラメータをご覧下さい)。
言語 ブラウザは Accept-Language ヘッダフィールドで優先傾向を指定します。 要素それぞれに品質数値を持たせることができます。 variants は 0 か 1 つかそれ以上の言語と 関連づけることができます。
エンコーディング ブラウザは Accept-Encoding ヘッダフィールドで優先傾向を指定します。 要素それぞれに品質数値を持たせることができます。
文字セット ブラウザは Accept-Charset ヘッダフィールドで優先傾向を指定します。 要素それぞれに品質数値を持たせることができます。 variant はメディアタイプのパラメータとして文字セットを 指定することもできます。

Apache ネゴシエーションアルゴリズム

ブラウザに返す「最適な」variant を (もしあれば) 選択するように Apache は次のアルゴリズムを使うことができます。 このアルゴリズムを設定により変更することはできません。 次のように動作します:

  1. まずはじめに、ネゴシエーションの次元それぞれについて適切な Accept* ヘッダフィールドを調べ、 variant それぞれに品質を割り当てます。 もしある次元の Accept* ヘッダでその variant が許容できないことが示されていれば、それを削除します。 variant が一つも残っていなければ、ステップ 4 に行きます。
  2. 消去法で「最適な」 variant を選びます。 次のテストが順番に適用されます。 テストで選択されなかった variant は削除されていきます。 テスト後 variant が一つだけ残っていれば、それを最適なものとして ステップ 3 に進みます。 複数 variant が残っていれば、次のテストに進みます。
    1. variant のメディアタイプの品質数値と Accept ヘッダの品質数値との積を計算して、最高値の variant を選びます。
    2. 言語品質数値が最高の variant を選びます。
    3. (もしあれば) Accept-Language ヘッダの言語順か、 (もしあれば) LanguagePriority ディレクティブの言語順で最適な言語の variant を選びます。
    4. 最高「レベル」のメディアパラメータ (text/html メディアタイプのバージョンを与えるために使われます) を持つ variant を選びます。
    5. Accept-Charset ヘッダ行で与えられている最高の文字セット メディアパラメータを持つ variant を選びます。 明示的に除外されていない限り、ISO-8859-1 が許容されるようになっています。 text/* メディアタイプであるけれども 特定の文字セットに明示的に関連づけられているわけではない variant は ISO-8859-1 であると仮定されます。
    6. ISO-8859-1 ではない文字セットメディアパラメータと 関連づけられている variant を選びます。 そのような variant がない場合は、代わりに全ての variant を選びます。
    7. 最適なエンコーディングの variant を選びます。 もし user-agent が許容するエンコーディングがあれば、 その variant のみを選びます。 そうではなく、もしエンコードされたものとそうでない variant が混ざって存在していたらエンコードされていない variant のみを選びます。 variant が全部エンコードされているか variant が全部エンコードされていないという場合は、 全ての variant を選びます。
    8. 内容の最も短い variant を選びます。
    9. 残っている variant の最初のものを選びます。 タイプマップファイルの最初にリストされているか、 variant がディレクトリから最初に読み込まれる時に ASCII順でソートしてファイル名が先頭になったか、のどちらかです。
  3. アルゴリズムを使って一つの「最適な」variant を選びましたので、 それを応答として返します。ネゴシエーションの次元を指定するために HTTP レスポンスヘッダ Vary が設定されます (リソースのキャッシュをする時に、 ブラウザやキャッシュはこの情報を使うことができます)。 以上で終わり。
  4. ここに来たということは、variant が一つも選択されなかった (ブラウザが許容するものがなかったため) ということです。 406 ステータス ("No Acceptable representation" を意味する) が、利用可能な variant のリストのついた HTML ドキュメントとともに返されます。 相違の次元を示す HTTP Vary ヘッダも設定されます。
top

品質の値を変える

上記の Apache ネゴシエーションアルゴリズムの厳格な解釈で 得られるであろう値から、Apache は品質数値を時々変えます。 これは、このアルゴリズムで完全ではない、あるいは正確でない情報を送る ブラウザ向けによりよい結果を得るために行われます。 かなりポピュラーなブラウザで、もしないと間違った variant を選択する結果になってしまうような Accept ヘッダ情報を送るものもあります。 ブラウザが完全で正しい情報を送っていれば、 この数値変化は適用されません。

メディアタイプとワイルドカード

Accept: リクエストヘッダはメディアタイプの優先傾向を指定します。 これはまた、"image/*" や "*/*" といった「ワイルドカード」メディアタイプを含むことができます。 ここで * は任意の文字列にマッチします。 ですから、次の:

Accept: image/*, */*

を含むリクエストは、"image/" ではじまるタイプ全てが許容できる、 そして他のどんなタイプも許容できる (この場合はじめの "image/*" は冗長になります) ことを示します。 扱うことのできる明示的なタイプに加えて、機械的に ワイルドカードを送るブラウザもあります。例えば:

Accept: text/html, text/plain, image/gif, image/jpeg, */*

こうすることの狙いは、明示的にリストしているタイプが優先されるけれども、 異なる表現が利用可能であればそれでも良い、ということです。 しかしながら、上の基本的なアルゴリズムでは、 */* ワイルドカードは他の全てのタイプと全く同等なので優先されません。 ブラウザは */* にもっと低い品質 (優先) 値を付けてリクエストを送るべきなのです。例えば:

Accept: text/html, text/plain, image/gif, image/jpeg, */*; q=0.01

明示的なタイプには品質数値が付けられていませんので、 デフォルトの 1.0 (最高値) の優先になります。 ワイルドカード */* は低い優先度 0.01 を与えられているので、 明示的にリストされているタイプに合致する variant がない場合にのみ、 他のタイプが返されます。

もし Accept: ヘッダが q 値を全く含んでいなければ、 望みの挙動をするために、 Apache は "*/*" があれば 0.01 の q 値を設定します。 また、"type/*" の形のワイルドカードには 0.02 の q 値を設定します (ですからこれらは "*/*" のマッチよりも優先されます)。 もし Accept: ヘッダ中のメディアタイプのどれかが q 値を含んでいれば、これらの特殊な値は適応されず、 正しい情報を送るブラウザからのリクエストは期待通りに 動作するようになります。

言語ネゴシエーションの例外処理

Apache 2.0 では新たに、言語ネゴシエーションが適合するものを 見つけるのに失敗した時に、優雅にフォールバックできるような ネゴシエーションアルゴリズムが幾つか追加されました。

サーバのページをクライアントがリクエストしたけれども、 ブラウザの送ってきた Accept-Language に合致するページが一つも 見つからなかった場合に、サーバは "No Acceptable Variant" か "Multiple Choices" レスポンスをクライアントに返します。 これらのエラーメッセージを返さないように、 このような場合には Apache が Accept-Language を無視して、 クライアントのリクエストに明示的には合致しないドキュメントを 提供するように設定できます。 ForceLanguagePriority ディレクティブは、これらのエラーの一つか両方をオーバーライドするために 使用できて、 LanguagePriority ディレクティブの内容を使ってサーバの判断を代行するようにできます。

サーバは他に適合するものが見つからなければ、 言語サブセットで適合するものを試そうともします。 例えばクライアントが英国英語である en-GB 言語で ドキュメントをリクエストした場合、サーバは HTTP/1.1 規格では、単に en とマークされているドキュメントを マッチするものとすることは通常は許されていません。 (英国英語は理解できるけど一般的な英語は理解できないという読み手は 考えられないので、Accept-Language ヘッダで en-GB を含んで en を含まないのはほぼ確実に設定の間違いである、 ということに注意してください。 ですが不幸なことに、多くのクライアントではデフォルトで このような設定になっています。) しかしながら、他の言語にはマッチせず、"No Acceptable Variants" エラーを返したり、 LanguagePriority にフォールバックしようとしているときは、 サブセット指定を無視して、en-GBen にマッチします。 Apache はクライアントの許容言語リストに暗黙に 非常に低い品質値の親言語を加えることになります。 しかし、クライアントが "en-GB; q=0.9, fr; q=0.8" とリクエストして、 サーバが "en" と "fr" と設計されたドキュメントを持っている場合は、 "fr" ドキュメントが返されることに注意してください。 このような処理は、HTTP 1.1 規格との整合性を維持して、 適切に設定されたクライアントともきちんと動作するために 必要です。

より高度なテクニック (Cookie や特殊な URL パス等) においてもユーザの言語選択をサポートするため、 Apache 2.0.47 からは、mod_negotiation環境変数 prefer-language を認識するようになりました。 この変数が存在して、適切な言語タグが代入されているのであれば、 mod_negotiation は合致する variant を選択しようとします。合致するものが無ければ、 通常のネゴシエーション手順が適用されます。

Example

SetEnvIf Cookie "language=(.+)" prefer-language=$1

top

Transparent Content Negotiation の拡張

Apache は transparent content negotiation プロトコル (RFC 2295) を次のように拡張しています。 特定のコンテントエンコーディングのみが利用可能である variant に印を付けるために、新たに {encoding ..} 要素を variant リスト中に使っています。 リスト中のエンコードされた variant を認識し、 Accept-Encoding リクエストヘッダに従って許容される エンコードをもった variant は、どれでも候補 variant として使用するように、 RVSA/1.0 アルゴリズム (RFC 2296) の実装が拡張されました。 RVSA/1.0 の実装では、最適な variant が見つかるまで、 計算した品質数値は小数点以下 5 桁まで丸めません。

top

リンクと名前の変換に関する注意点

言語ネゴシエーションを使っている場合は、 ファイルが一つ以上の拡張子を持てて、 拡張子の順番は通常は考慮されない (詳細は mod_mime を参照) ので、 幾つかの異なる名前の変換を選べることになります。

典型的なファイルでは、MIME タイプ拡張子 (例えば html) を持っていて、エンコーディング拡張子 (例えば gz) を持っているかもしれなくて、 このファイルに異なる言語 variant を用意していれば、 もちろん言語拡張子 (例えば en) を持っているでしょう。

例:

ファイル名と、それに対して使えるリンクと使えないリンクの例です:

ファイル名 使えるリンク 使えないリンク
foo.html.en foo
foo.html
-
foo.en.html foo foo.html
foo.html.en.gz foo
foo.html
foo.gz
foo.html.gz
foo.en.html.gz foo foo.html
foo.html.gz
foo.gz
foo.gz.html.en foo
foo.gz
foo.gz.html
foo.html
foo.html.gz.en foo
foo.html
foo.html.gz
foo.gz

上の表を見て、拡張子なしのリンク (例えば foo) がいつでも使えることに気が付くでしょう。 この利点は、ドキュメントとして応答するファイルの 実際のファイルタイプを隠蔽して、リンクの参照を変更することなく 後からファイルを変更できる、 例えば html から shtml に、あるいは cgi に変更できる点です。

リンクに MIME タイプを使い続けたい (例えば foo.html)時は、言語拡張子は (エンコーディング拡張子もあればそれも含めて) MIME タイプ拡張子の右側になければなりません (例えば foo.html.en)。

top

キャッシュに関する注意事項

キャッシュが一つの表現を保存しているときは、 リクエスト URL と関連づけられています。 次にその URL がリクエストされた時に、キャッシュは 保存されている表現を使用できます。しかし、 リソースがサーバでネゴシエーション可能であれば、 最初のリクエストでキャッシュされて続くキャッシュヒットでは 間違った応答を返してしまうということになりかねません。 これを防ぐために、Apache はコンテントネゴシエーションの 後に返された応答全てに、HTTP/1.0 クライアントでは キャッシュ不可能の印をつけます。 また、ネゴシエーションされた応答のキャッシュを可能にする HTTP/1.1 プロトコルの機能も Apache はサポートします。

HTTP/1.0 準拠のクライアントからのリクエストに対しては、 (ブラウザであろうとキャッシュであろうと) ネゴシエーションを受けた応答のキャッシュを許すために、 CacheNegotiatedDocs ディレクティブを使用できます。 このディレクティブは、サーバ設定ファイルやバーチャルホストに書くことができ、 引数をとりません。 HTTP/1.1 クライアントからのリクエストには効力を持ちません。

HTTP/1.1 クライアントに対しては、レスポンスのネゴシエーション次元 を示すために Vary HTTP レスポンスヘッダを送ります。 キャッシュは、これを使って後続のリクエストに対してローカルコピーで応答できるか どうかを決定できます。 ネゴシエーション次元とは関係なしにローカルコピーの使用を優先するようにするには、 force-no-vary 環境変数を 設定します。

custom-error.html100644 0 0 23001 11237400230 11540 0ustar 0 0 カスタムエラーレスポンス - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2

カスタムエラーレスポンス

This translation may be out of date. Check the English version for recent changes.

ウェブマスターが何らかのエラーや問題に対する Apache の反応を設定できるようにする追加機能を提供します。

サーバがエラーや問題を発見した場合の反応を、 カスタマイズして定義することができます。

スクリプトの実行が失敗して "500 Server Error" を発生させたとします。この場合の反応を、より好ましいテキストや、別の URL (内部及び外部) へのリダイレクションに置き換えることができます。

top

動作

古い動作

NCSA httpd 1.3 は、古くて退屈なエラー/問題メッセージを 返していました。それはしばしばユーザには無意味であり、 またそれを発生させた原因を記録する方法も提供していませんでした。

新しい動作

  1. NCSA のハードコードされたメッセージの代わりに 他のテキストを表示
  2. ローカルの URL にリダイレクト
  3. 外部の URL にリダイレクト

するようにサーバを設定できます。

別の URL にリダイレクトすることは役に立ちますが、 それは説明をしたり、より明確に誤り/問題を記録したりするために 何か情報を伝えられるときに限ります。

これを実現するために、 Apache は新しく CGI のような環境変数を 定義します:

REDIRECT_HTTP_ACCEPT=*/*, image/gif, image/x-xbitmap, image/jpeg
REDIRECT_HTTP_USER_AGENT=Mozilla/1.1b2 (X11; I; HP-UX A.09.05 9000/712)
REDIRECT_PATH=.:/bin:/usr/local/bin:/etc
REDIRECT_QUERY_STRING=
REDIRECT_REMOTE_ADDR=121.345.78.123
REDIRECT_REMOTE_HOST=ooh.ahhh.com
REDIRECT_SERVER_NAME=crash.bang.edu
REDIRECT_SERVER_PORT=80
REDIRECT_SERVER_SOFTWARE=Apache/0.8.15
REDIRECT_URL=/cgi-bin/buggy.pl

頭に付く REDIRECT_ に注目してください。

少なくとも REDIRECT_URLREDIRECT_QUERY_STRING は新しい URL (CGI スクリプトか CGI インクルードであると仮定されます) に渡されます。 他の変数は、エラーや問題が起きる前に存在した場合にだけ存在します。 もしあなたの設定した ErrorDocument外部リダイレクト (すなわちhttp: のような体系名から始まるすべてのもの。たとえ同じホストを指していても) ならば、これらはまったく設定されません。

top

設定

AllowOverride が適切に設定されていれば、 .htaccess ファイルで ErrorDocument を使用することができます。

ここに、いくつかの例を挙げます。

ErrorDocument 500 /cgi-bin/crash-recover
ErrorDocument 500 "Sorry, our script crashed. Oh dear"
ErrorDocument 500 http://xxx/
ErrorDocument 404 /Lame_excuses/not_found.html
ErrorDocument 401 /Subscription/how_to_subscribe.html

構文

ErrorDocument <3-digit-code> <action>

action (動作) は、

  1. 表示されるべきテキスト。テキストには引用符 (") をつけます。 引用符の後に続くものが何でも表示されます。 注意 : (") は表示されません
  2. リダイレクト先の外部 URL
  3. リダイレクト先のローカル URL
top

カスタムエラーレスポンスとリダイレクト

スクリプト/SSI に追加の環境変数が利用可能になるように、 リダイレクトされた URL に対する Apache の動作が変更されました。

古い動作

リダイレクトされたスクリプトは標準の CGI 環境変数を利用可能でした。しかし、どこからリダイレクト されたかの情報は提供されていませんでした。

新しい動作

リダイレクトされた先のスクリプトが使用可能なように、 新しいたくさんの環境変数が初期化されます。新しい変数は、それぞれ REDIRECT_ で始まります。 REDIRECT_ で始まる環境変数はリダイレクトされる前に存在していた CGI 環境変数の頭に REDIRECT_ を付けて作成されます。 すなわちHTTP_USER_AGENTREDIRECT_HTTP_USER_AGENT になります。 これらの新しい変数に加えて、Apache は、 スクリプトがリダイレクト元のトレースを助けるために REDIRECT_URLREDIRECT_STATUS を定義します。アクセスログには元の URL とリダイレクトされた URL の両方が記録されます。

ErrorDocument が CGI スクリプトへのローカルリダイレクトを 指定している場合は、それを起動することになったエラーの状態を クライアントまで確実に伝えるために "Status:" ヘッダを含むべきです。例えば、ErrorDocument 用の Perl スクリプトは以下のようなものを含むかもしれません。

...
print "Content-type: text/html\n";
printf "Status: %s Condition Intercepted\n", $ENV{"REDIRECT_STATUS"};
...

スクリプトが 404 Not Found のような 特定のエラーコンディションを扱うためだけに使われる場合は、 代わりに特定のコードとエラーテキストを使用することができます。

developer/API.html100644 0 0 172304 11237400230 11530 0ustar 0 0 Apache 1.3 API notes - Apache HTTP Server
<-
Apache > HTTP Server > Documentation > Version 2.2 > Developer Documentation

Apache 1.3 API notes

Warning

This document has not been updated to take into account changes made in the 2.0 version of the Apache HTTP Server. Some of the information may still be relevant, but please use it with care.

These are some notes on the Apache API and the data structures you have to deal with, etc. They are not yet nearly complete, but hopefully, they will help you get your bearings. Keep in mind that the API is still subject to change as we gain experience with it. (See the TODO file for what might be coming). However, it will be easy to adapt modules to any changes that are made. (We have more modules to adapt than you do).

A few notes on general pedagogical style here. In the interest of conciseness, all structure declarations here are incomplete -- the real ones have more slots that I'm not telling you about. For the most part, these are reserved to one component of the server core or another, and should be altered by modules with caution. However, in some cases, they really are things I just haven't gotten around to yet. Welcome to the bleeding edge.

Finally, here's an outline, to give you some bare idea of what's coming up, and in what order:

top

Basic concepts

We begin with an overview of the basic concepts behind the API, and how they are manifested in the code.

Handlers, Modules, and Requests

Apache breaks down request handling into a series of steps, more or less the same way the Netscape server API does (although this API has a few more stages than NetSite does, as hooks for stuff I thought might be useful in the future). These are:

These phases are handled by looking at each of a succession of modules, looking to see if each of them has a handler for the phase, and attempting invoking it if so. The handler can typically do one of three things:

Most phases are terminated by the first module that handles them; however, for logging, `fixups', and non-access authentication checking, all handlers always run (barring an error). Also, the response phase is unique in that modules may declare multiple handlers for it, via a dispatch table keyed on the MIME type of the requested object. Modules may declare a response-phase handler which can handle any request, by giving it the key */* (i.e., a wildcard MIME type specification). However, wildcard handlers are only invoked if the server has already tried and failed to find a more specific response handler for the MIME type of the requested object (either none existed, or they all declined).

The handlers themselves are functions of one argument (a request_rec structure. vide infra), which returns an integer, as above.

A brief tour of a module

At this point, we need to explain the structure of a module. Our candidate will be one of the messier ones, the CGI module -- this handles both CGI scripts and the ScriptAlias config file command. It's actually a great deal more complicated than most modules, but if we're going to have only one example, it might as well be the one with its fingers in every place.

Let's begin with handlers. In order to handle the CGI scripts, the module declares a response handler for them. Because of ScriptAlias, it also has handlers for the name translation phase (to recognize ScriptAliased URIs), the type-checking phase (any ScriptAliased request is typed as a CGI script).

The module needs to maintain some per (virtual) server information, namely, the ScriptAliases in effect; the module structure therefore contains pointers to a functions which builds these structures, and to another which combines two of them (in case the main server and a virtual server both have ScriptAliases declared).

Finally, this module contains code to handle the ScriptAlias command itself. This particular module only declares one command, but there could be more, so modules have command tables which declare their commands, and describe where they are permitted, and how they are to be invoked.

A final note on the declared types of the arguments of some of these commands: a pool is a pointer to a resource pool structure; these are used by the server to keep track of the memory which has been allocated, files opened, etc., either to service a particular request, or to handle the process of configuring itself. That way, when the request is over (or, for the configuration pool, when the server is restarting), the memory can be freed, and the files closed, en masse, without anyone having to write explicit code to track them all down and dispose of them. Also, a cmd_parms structure contains various information about the config file being read, and other status information, which is sometimes of use to the function which processes a config-file command (such as ScriptAlias). With no further ado, the module itself:

/* Declarations of handlers. */

int translate_scriptalias (request_rec *);
int type_scriptalias (request_rec *);
int cgi_handler (request_rec *);

/* Subsidiary dispatch table for response-phase
 * handlers, by MIME type */

handler_rec cgi_handlers[] = {
{ "application/x-httpd-cgi", cgi_handler },
{ NULL }
};

/* Declarations of routines to manipulate the
 * module's configuration info. Note that these are
 * returned, and passed in, as void *'s; the server
 * core keeps track of them, but it doesn't, and can't,
 * know their internal structure.
 */

void *make_cgi_server_config (pool *);
void *merge_cgi_server_config (pool *, void *, void *);

/* Declarations of routines to handle config-file commands */

extern char *script_alias(cmd_parms *, void *per_dir_config, char *fake, char *real);

command_rec cgi_cmds[] = {
{ "ScriptAlias", script_alias, NULL, RSRC_CONF, TAKE2,
"a fakename and a realname"},
{ NULL }
};

module cgi_module = {

  STANDARD_MODULE_STUFF,
  NULL,                     /* initializer */
  NULL,                     /* dir config creator */
  NULL,                     /* dir merger */
  make_cgi_server_config,   /* server config */
  merge_cgi_server_config,  /* merge server config */
  cgi_cmds,                 /* command table */
  cgi_handlers,             /* handlers */
  translate_scriptalias,    /* filename translation */
  NULL,                     /* check_user_id */
  NULL,                     /* check auth */
  NULL,                     /* check access */
  type_scriptalias,         /* type_checker */
  NULL,                     /* fixups */
  NULL,                     /* logger */
  NULL                      /* header parser */
};
top

How handlers work

The sole argument to handlers is a request_rec structure. This structure describes a particular request which has been made to the server, on behalf of a client. In most cases, each connection to the client generates only one request_rec structure.

A brief tour of the request_rec

The request_rec contains pointers to a resource pool which will be cleared when the server is finished handling the request; to structures containing per-server and per-connection information, and most importantly, information on the request itself.

The most important such information is a small set of character strings describing attributes of the object being requested, including its URI, filename, content-type and content-encoding (these being filled in by the translation and type-check handlers which handle the request, respectively).

Other commonly used data items are tables giving the MIME headers on the client's original request, MIME headers to be sent back with the response (which modules can add to at will), and environment variables for any subprocesses which are spawned off in the course of servicing the request. These tables are manipulated using the ap_table_get and ap_table_set routines.

Note that the Content-type header value cannot be set by module content-handlers using the ap_table_*() routines. Rather, it is set by pointing the content_type field in the request_rec structure to an appropriate string. e.g.,

r->content_type = "text/html";

Finally, there are pointers to two data structures which, in turn, point to per-module configuration structures. Specifically, these hold pointers to the data structures which the module has built to describe the way it has been configured to operate in a given directory (via .htaccess files or <Directory> sections), for private data it has built in the course of servicing the request (so modules' handlers for one phase can pass `notes' to their handlers for other phases). There is another such configuration vector in the server_rec data structure pointed to by the request_rec, which contains per (virtual) server configuration data.

Here is an abridged declaration, giving the fields most commonly used:

struct request_rec {

pool *pool;
conn_rec *connection;
server_rec *server;

/* What object is being requested */

char *uri;
char *filename;
char *path_info;

char *args;           /* QUERY_ARGS, if any */
struct stat finfo;    /* Set by server core;
                       * st_mode set to zero if no such file */

char *content_type;
char *content_encoding;

/* MIME header environments, in and out. Also,
 * an array containing environment variables to
 * be passed to subprocesses, so people can write
 * modules to add to that environment.
 *
 * The difference between headers_out and
 * err_headers_out is that the latter are printed
 * even on error, and persist across internal
 * redirects (so the headers printed for
 * ErrorDocument handlers will have them).
 */

table *headers_in;
table *headers_out;
table *err_headers_out;
table *subprocess_env;

/* Info about the request itself... */

int header_only;     /* HEAD request, as opposed to GET */
char *protocol;      /* Protocol, as given to us, or HTTP/0.9 */
char *method;        /* GET, HEAD, POST, etc. */
int method_number;   /* M_GET, M_POST, etc. */

/* Info for logging */

char *the_request;
int bytes_sent;

/* A flag which modules can set, to indicate that
 * the data being returned is volatile, and clients
 * should be told not to cache it.
 */

int no_cache;

/* Various other config info which may change
 * with .htaccess files
 * These are config vectors, with one void*
 * pointer for each module (the thing pointed
 * to being the module's business).
 */

void *per_dir_config;   /* Options set in config files, etc. */
void *request_config;   /* Notes on *this* request */


};

Where request_rec structures come from

Most request_rec structures are built by reading an HTTP request from a client, and filling in the fields. However, there are a few exceptions:

Handling requests, declining, and returning error codes

As discussed above, each handler, when invoked to handle a particular request_rec, has to return an int to indicate what happened. That can either be

Note that if the error code returned is REDIRECT, then the module should put a Location in the request's headers_out, to indicate where the client should be redirected to.

Special considerations for response handlers

Handlers for most phases do their work by simply setting a few fields in the request_rec structure (or, in the case of access checkers, simply by returning the correct error code). However, response handlers have to actually send a request back to the client.

They should begin by sending an HTTP response header, using the function ap_send_http_header. (You don't have to do anything special to skip sending the header for HTTP/0.9 requests; the function figures out on its own that it shouldn't do anything). If the request is marked header_only, that's all they should do; they should return after that, without attempting any further output.

Otherwise, they should produce a request body which responds to the client as appropriate. The primitives for this are ap_rputc and ap_rprintf, for internally generated output, and ap_send_fd, to copy the contents of some FILE * straight to the client.

At this point, you should more or less understand the following piece of code, which is the handler which handles GET requests which have no more specific handler; it also shows how conditional GETs can be handled, if it's desirable to do so in a particular response handler -- ap_set_last_modified checks against the If-modified-since value supplied by the client, if any, and returns an appropriate code (which will, if nonzero, be USE_LOCAL_COPY). No similar considerations apply for ap_set_content_length, but it returns an error code for symmetry.

int default_handler (request_rec *r)
{
int errstatus;
FILE *f;

if (r->method_number != M_GET) return DECLINED;
if (r->finfo.st_mode == 0) return NOT_FOUND;

if ((errstatus = ap_set_content_length (r, r->finfo.st_size))
    || (errstatus = ap_set_last_modified (r, r->finfo.st_mtime)))
return errstatus;

f = fopen (r->filename, "r");

if (f == NULL) {
log_reason("file permissions deny server access", r->filename, r);
return FORBIDDEN;
}

register_timeout ("send", r);
ap_send_http_header (r);

if (!r->header_only) send_fd (f, r);
ap_pfclose (r->pool, f);
return OK;
}

Finally, if all of this is too much of a challenge, there are a few ways out of it. First off, as shown above, a response handler which has not yet produced any output can simply return an error code, in which case the server will automatically produce an error response. Secondly, it can punt to some other handler by invoking ap_internal_redirect, which is how the internal redirection machinery discussed above is invoked. A response handler which has internally redirected should always return OK.

(Invoking ap_internal_redirect from handlers which are not response handlers will lead to serious confusion).

Special considerations for authentication handlers

Stuff that should be discussed here in detail:

Special considerations for logging handlers

When a request has internally redirected, there is the question of what to log. Apache handles this by bundling the entire chain of redirects into a list of request_rec structures which are threaded through the r->prev and r->next pointers. The request_rec which is passed to the logging handlers in such cases is the one which was originally built for the initial request from the client; note that the bytes_sent field will only be correct in the last request in the chain (the one for which a response was actually sent).

top

Resource allocation and resource pools

One of the problems of writing and designing a server-pool server is that of preventing leakage, that is, allocating resources (memory, open files, etc.), without subsequently releasing them. The resource pool machinery is designed to make it easy to prevent this from happening, by allowing resource to be allocated in such a way that they are automatically released when the server is done with them.

The way this works is as follows: the memory which is allocated, file opened, etc., to deal with a particular request are tied to a resource pool which is allocated for the request. The pool is a data structure which itself tracks the resources in question.

When the request has been processed, the pool is cleared. At that point, all the memory associated with it is released for reuse, all files associated with it are closed, and any other clean-up functions which are associated with the pool are run. When this is over, we can be confident that all the resource tied to the pool have been released, and that none of them have leaked.

Server restarts, and allocation of memory and resources for per-server configuration, are handled in a similar way. There is a configuration pool, which keeps track of resources which were allocated while reading the server configuration files, and handling the commands therein (for instance, the memory that was allocated for per-server module configuration, log files and other files that were opened, and so forth). When the server restarts, and has to reread the configuration files, the configuration pool is cleared, and so the memory and file descriptors which were taken up by reading them the last time are made available for reuse.

It should be noted that use of the pool machinery isn't generally obligatory, except for situations like logging handlers, where you really need to register cleanups to make sure that the log file gets closed when the server restarts (this is most easily done by using the function ap_pfopen, which also arranges for the underlying file descriptor to be closed before any child processes, such as for CGI scripts, are execed), or in case you are using the timeout machinery (which isn't yet even documented here). However, there are two benefits to using it: resources allocated to a pool never leak (even if you allocate a scratch string, and just forget about it); also, for memory allocation, ap_palloc is generally faster than malloc.

We begin here by describing how memory is allocated to pools, and then discuss how other resources are tracked by the resource pool machinery.

Allocation of memory in pools

Memory is allocated to pools by calling the function ap_palloc, which takes two arguments, one being a pointer to a resource pool structure, and the other being the amount of memory to allocate (in chars). Within handlers for handling requests, the most common way of getting a resource pool structure is by looking at the pool slot of the relevant request_rec; hence the repeated appearance of the following idiom in module code:

int my_handler(request_rec *r)
{
struct my_structure *foo;
...

foo = (foo *)ap_palloc (r->pool, sizeof(my_structure));
}

Note that there is no ap_pfree -- ap_palloced memory is freed only when the associated resource pool is cleared. This means that ap_palloc does not have to do as much accounting as malloc(); all it does in the typical case is to round up the size, bump a pointer, and do a range check.

(It also raises the possibility that heavy use of ap_palloc could cause a server process to grow excessively large. There are two ways to deal with this, which are dealt with below; briefly, you can use malloc, and try to be sure that all of the memory gets explicitly freed, or you can allocate a sub-pool of the main pool, allocate your memory in the sub-pool, and clear it out periodically. The latter technique is discussed in the section on sub-pools below, and is used in the directory-indexing code, in order to avoid excessive storage allocation when listing directories with thousands of files).

Allocating initialized memory

There are functions which allocate initialized memory, and are frequently useful. The function ap_pcalloc has the same interface as ap_palloc, but clears out the memory it allocates before it returns it. The function ap_pstrdup takes a resource pool and a char * as arguments, and allocates memory for a copy of the string the pointer points to, returning a pointer to the copy. Finally ap_pstrcat is a varargs-style function, which takes a pointer to a resource pool, and at least two char * arguments, the last of which must be NULL. It allocates enough memory to fit copies of each of the strings, as a unit; for instance:

ap_pstrcat (r->pool, "foo", "/", "bar", NULL);

returns a pointer to 8 bytes worth of memory, initialized to "foo/bar".

Commonly-used pools in the Apache Web server

A pool is really defined by its lifetime more than anything else. There are some static pools in http_main which are passed to various non-http_main functions as arguments at opportune times. Here they are:

permanent_pool
never passed to anything else, this is the ancestor of all pools
pconf
  • subpool of permanent_pool
  • created at the beginning of a config "cycle"; exists until the server is terminated or restarts; passed to all config-time routines, either via cmd->pool, or as the "pool *p" argument on those which don't take pools
  • passed to the module init() functions
ptemp
  • sorry I lie, this pool isn't called this currently in 1.3, I renamed it this in my pthreads development. I'm referring to the use of ptrans in the parent... contrast this with the later definition of ptrans in the child.
  • subpool of permanent_pool
  • created at the beginning of a config "cycle"; exists until the end of config parsing; passed to config-time routines via cmd->temp_pool. Somewhat of a "bastard child" because it isn't available everywhere. Used for temporary scratch space which may be needed by some config routines but which is deleted at the end of config.
pchild
  • subpool of permanent_pool
  • created when a child is spawned (or a thread is created); lives until that child (thread) is destroyed
  • passed to the module child_init functions
  • destruction happens right after the child_exit functions are called... (which may explain why I think child_exit is redundant and unneeded)
ptrans
  • should be a subpool of pchild, but currently is a subpool of permanent_pool, see above
  • cleared by the child before going into the accept() loop to receive a connection
  • used as connection->pool
r->pool
  • for the main request this is a subpool of connection->pool; for subrequests it is a subpool of the parent request's pool.
  • exists until the end of the request (i.e., ap_destroy_sub_req, or in child_main after process_request has finished)
  • note that r itself is allocated from r->pool; i.e., r->pool is first created and then r is the first thing palloc()d from it

For almost everything folks do, r->pool is the pool to use. But you can see how other lifetimes, such as pchild, are useful to some modules... such as modules that need to open a database connection once per child, and wish to clean it up when the child dies.

You can also see how some bugs have manifested themself, such as setting connection->user to a value from r->pool -- in this case connection exists for the lifetime of ptrans, which is longer than r->pool (especially if r->pool is a subrequest!). So the correct thing to do is to allocate from connection->pool.

And there was another interesting bug in mod_include / mod_cgi. You'll see in those that they do this test to decide if they should use r->pool or r->main->pool. In this case the resource that they are registering for cleanup is a child process. If it were registered in r->pool, then the code would wait() for the child when the subrequest finishes. With mod_include this could be any old #include, and the delay can be up to 3 seconds... and happened quite frequently. Instead the subprocess is registered in r->main->pool which causes it to be cleaned up when the entire request is done -- i.e., after the output has been sent to the client and logging has happened.

Tracking open files, etc.

As indicated above, resource pools are also used to track other sorts of resources besides memory. The most common are open files. The routine which is typically used for this is ap_pfopen, which takes a resource pool and two strings as arguments; the strings are the same as the typical arguments to fopen, e.g.,

...
FILE *f = ap_pfopen (r->pool, r->filename, "r");

if (f == NULL) { ... } else { ... }

There is also a ap_popenf routine, which parallels the lower-level open system call. Both of these routines arrange for the file to be closed when the resource pool in question is cleared.

Unlike the case for memory, there are functions to close files allocated with ap_pfopen, and ap_popenf, namely ap_pfclose and ap_pclosef. (This is because, on many systems, the number of files which a single process can have open is quite limited). It is important to use these functions to close files allocated with ap_pfopen and ap_popenf, since to do otherwise could cause fatal errors on systems such as Linux, which react badly if the same FILE* is closed more than once.

(Using the close functions is not mandatory, since the file will eventually be closed regardless, but you should consider it in cases where your module is opening, or could open, a lot of files).

Other sorts of resources -- cleanup functions

More text goes here. Describe the cleanup primitives in terms of which the file stuff is implemented; also, spawn_process.

Pool cleanups live until clear_pool() is called: clear_pool(a) recursively calls destroy_pool() on all subpools of a; then calls all the cleanups for a; then releases all the memory for a. destroy_pool(a) calls clear_pool(a) and then releases the pool structure itself. i.e., clear_pool(a) doesn't delete a, it just frees up all the resources and you can start using it again immediately.

Fine control -- creating and dealing with sub-pools, with a note on sub-requests

On rare occasions, too-free use of ap_palloc() and the associated primitives may result in undesirably profligate resource allocation. You can deal with such a case by creating a sub-pool, allocating within the sub-pool rather than the main pool, and clearing or destroying the sub-pool, which releases the resources which were associated with it. (This really is a rare situation; the only case in which it comes up in the standard module set is in case of listing directories, and then only with very large directories. Unnecessary use of the primitives discussed here can hair up your code quite a bit, with very little gain).

The primitive for creating a sub-pool is ap_make_sub_pool, which takes another pool (the parent pool) as an argument. When the main pool is cleared, the sub-pool will be destroyed. The sub-pool may also be cleared or destroyed at any time, by calling the functions ap_clear_pool and ap_destroy_pool, respectively. (The difference is that ap_clear_pool frees resources associated with the pool, while ap_destroy_pool also deallocates the pool itself. In the former case, you can allocate new resources within the pool, and clear it again, and so forth; in the latter case, it is simply gone).

One final note -- sub-requests have their own resource pools, which are sub-pools of the resource pool for the main request. The polite way to reclaim the resources associated with a sub request which you have allocated (using the ap_sub_req_... functions) is ap_destroy_sub_req, which frees the resource pool. Before calling this function, be sure to copy anything that you care about which might be allocated in the sub-request's resource pool into someplace a little less volatile (for instance, the filename in its request_rec structure).

(Again, under most circumstances, you shouldn't feel obliged to call this function; only 2K of memory or so are allocated for a typical sub request, and it will be freed anyway when the main request pool is cleared. It is only when you are allocating many, many sub-requests for a single main request that you should seriously consider the ap_destroy_... functions).

top

Configuration, commands and the like

One of the design goals for this server was to maintain external compatibility with the NCSA 1.3 server --- that is, to read the same configuration files, to process all the directives therein correctly, and in general to be a drop-in replacement for NCSA. On the other hand, another design goal was to move as much of the server's functionality into modules which have as little as possible to do with the monolithic server core. The only way to reconcile these goals is to move the handling of most commands from the central server into the modules.

However, just giving the modules command tables is not enough to divorce them completely from the server core. The server has to remember the commands in order to act on them later. That involves maintaining data which is private to the modules, and which can be either per-server, or per-directory. Most things are per-directory, including in particular access control and authorization information, but also information on how to determine file types from suffixes, which can be modified by AddType and DefaultType directives, and so forth. In general, the governing philosophy is that anything which can be made configurable by directory should be; per-server information is generally used in the standard set of modules for information like Aliases and Redirects which come into play before the request is tied to a particular place in the underlying file system.

Another requirement for emulating the NCSA server is being able to handle the per-directory configuration files, generally called .htaccess files, though even in the NCSA server they can contain directives which have nothing at all to do with access control. Accordingly, after URI -> filename translation, but before performing any other phase, the server walks down the directory hierarchy of the underlying filesystem, following the translated pathname, to read any .htaccess files which might be present. The information which is read in then has to be merged with the applicable information from the server's own config files (either from the <Directory> sections in access.conf, or from defaults in srm.conf, which actually behaves for most purposes almost exactly like <Directory />).

Finally, after having served a request which involved reading .htaccess files, we need to discard the storage allocated for handling them. That is solved the same way it is solved wherever else similar problems come up, by tying those structures to the per-transaction resource pool.

Per-directory configuration structures

Let's look out how all of this plays out in mod_mime.c, which defines the file typing handler which emulates the NCSA server's behavior of determining file types from suffixes. What we'll be looking at, here, is the code which implements the AddType and AddEncoding commands. These commands can appear in .htaccess files, so they must be handled in the module's private per-directory data, which in fact, consists of two separate tables for MIME types and encoding information, and is declared as follows:

typedef struct {
    table *forced_types;      /* Additional AddTyped stuff */
    table *encoding_types;    /* Added with AddEncoding... */
} mime_dir_config;

When the server is reading a configuration file, or <Directory> section, which includes one of the MIME module's commands, it needs to create a mime_dir_config structure, so those commands have something to act on. It does this by invoking the function it finds in the module's `create per-dir config slot', with two arguments: the name of the directory to which this configuration information applies (or NULL for srm.conf), and a pointer to a resource pool in which the allocation should happen.

(If we are reading a .htaccess file, that resource pool is the per-request resource pool for the request; otherwise it is a resource pool which is used for configuration data, and cleared on restarts. Either way, it is important for the structure being created to vanish when the pool is cleared, by registering a cleanup on the pool if necessary).

For the MIME module, the per-dir config creation function just ap_pallocs the structure above, and a creates a couple of tables to fill it. That looks like this:

void *create_mime_dir_config (pool *p, char *dummy)
{
mime_dir_config *new =
(mime_dir_config *) ap_palloc (p, sizeof(mime_dir_config));

new->forced_types = ap_make_table (p, 4);
new->encoding_types = ap_make_table (p, 4);

return new;
}

Now, suppose we've just read in a .htaccess file. We already have the per-directory configuration structure for the next directory up in the hierarchy. If the .htaccess file we just read in didn't have any AddType or AddEncoding commands, its per-directory config structure for the MIME module is still valid, and we can just use it. Otherwise, we need to merge the two structures somehow.

To do that, the server invokes the module's per-directory config merge function, if one is present. That function takes three arguments: the two structures being merged, and a resource pool in which to allocate the result. For the MIME module, all that needs to be done is overlay the tables from the new per-directory config structure with those from the parent:

void *merge_mime_dir_configs (pool *p, void *parent_dirv, void *subdirv)
{
mime_dir_config *parent_dir = (mime_dir_config *)parent_dirv;
mime_dir_config *subdir = (mime_dir_config *)subdirv;
mime_dir_config *new =
(mime_dir_config *)ap_palloc (p, sizeof(mime_dir_config));

new->forced_types = ap_overlay_tables (p, subdir->forced_types,
parent_dir->forced_types);
new->encoding_types = ap_overlay_tables (p, subdir->encoding_types,
parent_dir->encoding_types);

return new;
}

As a note -- if there is no per-directory merge function present, the server will just use the subdirectory's configuration info, and ignore the parent's. For some modules, that works just fine (e.g., for the includes module, whose per-directory configuration information consists solely of the state of the XBITHACK), and for those modules, you can just not declare one, and leave the corresponding structure slot in the module itself NULL.

Command handling

Now that we have these structures, we need to be able to figure out how to fill them. That involves processing the actual AddType and AddEncoding commands. To find commands, the server looks in the module's command table. That table contains information on how many arguments the commands take, and in what formats, where it is permitted, and so forth. That information is sufficient to allow the server to invoke most command-handling functions with pre-parsed arguments. Without further ado, let's look at the AddType command handler, which looks like this (the AddEncoding command looks basically the same, and won't be shown here):

char *add_type(cmd_parms *cmd, mime_dir_config *m, char *ct, char *ext)
{
if (*ext == '.') ++ext;
ap_table_set (m->forced_types, ext, ct);
return NULL;
}

This command handler is unusually simple. As you can see, it takes four arguments, two of which are pre-parsed arguments, the third being the per-directory configuration structure for the module in question, and the fourth being a pointer to a cmd_parms structure. That structure contains a bunch of arguments which are frequently of use to some, but not all, commands, including a resource pool (from which memory can be allocated, and to which cleanups should be tied), and the (virtual) server being configured, from which the module's per-server configuration data can be obtained if required.

Another way in which this particular command handler is unusually simple is that there are no error conditions which it can encounter. If there were, it could return an error message instead of NULL; this causes an error to be printed out on the server's stderr, followed by a quick exit, if it is in the main config files; for a .htaccess file, the syntax error is logged in the server error log (along with an indication of where it came from), and the request is bounced with a server error response (HTTP error status, code 500).

The MIME module's command table has entries for these commands, which look like this:

command_rec mime_cmds[] = {
{ "AddType", add_type, NULL, OR_FILEINFO, TAKE2,
"a mime type followed by a file extension" },
{ "AddEncoding", add_encoding, NULL, OR_FILEINFO, TAKE2,
"an encoding (e.g., gzip), followed by a file extension" },
{ NULL }
};

The entries in these tables are:

Finally, having set this all up, we have to use it. This is ultimately done in the module's handlers, specifically for its file-typing handler, which looks more or less like this; note that the per-directory configuration structure is extracted from the request_rec's per-directory configuration vector by using the ap_get_module_config function.

int find_ct(request_rec *r)
{
int i;
char *fn = ap_pstrdup (r->pool, r->filename);
mime_dir_config *conf = (mime_dir_config *)
ap_get_module_config(r->per_dir_config, &mime_module);
char *type;

if (S_ISDIR(r->finfo.st_mode)) {
r->content_type = DIR_MAGIC_TYPE;
return OK;
}

if((i=ap_rind(fn,'.')) < 0) return DECLINED;
++i;

if ((type = ap_table_get (conf->encoding_types, &fn[i])))
{
r->content_encoding = type;

/* go back to previous extension to try to use it as a type */
fn[i-1] = '\0';
if((i=ap_rind(fn,'.')) < 0) return OK;
++i;
}

if ((type = ap_table_get (conf->forced_types, &fn[i])))
{
r->content_type = type;
}

return OK;
}

Side notes -- per-server configuration, virtual servers, etc.

The basic ideas behind per-server module configuration are basically the same as those for per-directory configuration; there is a creation function and a merge function, the latter being invoked where a virtual server has partially overridden the base server configuration, and a combined structure must be computed. (As with per-directory configuration, the default if no merge function is specified, and a module is configured in some virtual server, is that the base configuration is simply ignored).

The only substantial difference is that when a command needs to configure the per-server private module data, it needs to go to the cmd_parms data to get at it. Here's an example, from the alias module, which also indicates how a syntax error can be returned (note that the per-directory configuration argument to the command handler is declared as a dummy, since the module doesn't actually have per-directory config data):

char *add_redirect(cmd_parms *cmd, void *dummy, char *f, char *url)
{
server_rec *s = cmd->server;
alias_server_conf *conf = (alias_server_conf *)
ap_get_module_config(s->module_config,&alias_module);
alias_entry *new = ap_push_array (conf->redirects);

if (!ap_is_url (url)) return "Redirect to non-URL";

new->fake = f; new->real = url;
return NULL;
}

developer/debugging.html100644 0 0 21562 11237400230 13031 0ustar 0 0 Debugging Memory Allocation in APR - Apache HTTP Server
<-
Apache > HTTP Server > Documentation > Version 2.2 > Developer Documentation

Debugging Memory Allocation in APR

The allocation mechanisms within APR have a number of debugging modes that can be used to assist in finding memory problems. This document describes the modes available and gives instructions on activating them.

top

Available debugging options

Allocation Debugging - ALLOC_DEBUG

Debugging support: Define this to enable code which helps detect re-use of free()d memory and other such nonsense.

The theory is simple. The FILL_BYTE (0xa5) is written over all malloc'd memory as we receive it, and is written over everything that we free up during a clear_pool. We check that blocks on the free list always have the FILL_BYTE in them, and we check during palloc() that the bytes still have FILL_BYTE in them. If you ever see garbage URLs or whatnot containing lots of 0xa5s then you know something used data that's been freed or uninitialized.

Malloc Support - ALLOC_USE_MALLOC

If defined all allocations will be done with malloc() and free()d appropriately at the end.

This is intended to be used with something like Electric Fence or Purify to help detect memory problems. Note that if you're using efence then you should also add in ALLOC_DEBUG. But don't add in ALLOC_DEBUG if you're using Purify because ALLOC_DEBUG would hide all the uninitialized read errors that Purify can diagnose.

Pool Debugging - POOL_DEBUG

This is intended to detect cases where the wrong pool is used when assigning data to an object in another pool.

In particular, it causes the table_{set,add,merge}n routines to check that their arguments are safe for the apr_table_t they're being placed in. It currently only works with the unix multiprocess model, but could be extended to others.

Table Debugging - MAKE_TABLE_PROFILE

Provide diagnostic information about make_table() calls which are possibly too small.

This requires a recent gcc which supports __builtin_return_address(). The error_log output will be a message such as:

table_push: apr_table_t created by 0x804d874 hit limit of 10

Use l *0x804d874 to find the source that corresponds to. It indicates that a apr_table_t allocated by a call at that address has possibly too small an initial apr_table_t size guess.

Allocation Statistics - ALLOC_STATS

Provide some statistics on the cost of allocations.

This requires a bit of an understanding of how alloc.c works.

top

Allowable Combinations

Not all the options outlined above can be activated at the same time. the following table gives more information.

ALLOC DEBUG ALLOC USE MALLOC POOL DEBUG MAKE TABLE PROFILE ALLOC STATS
ALLOC DEBUG -NoYesYesYes
ALLOC USE MALLOC No-NoNoNo
POOL DEBUG YesNo-YesYes
MAKE TABLE PROFILE YesNoYes-Yes
ALLOC STATS YesNoYesYes-

Additionally the debugging options are not suitable for multi-threaded versions of the server. When trying to debug with these options the server should be started in single process mode.

top

Activating Debugging Options

The various options for debugging memory are now enabled in the apr_general.h header file in APR. The various options are enabled by uncommenting the define for the option you wish to use. The section of the code currently looks like this (contained in srclib/apr/include/apr_pools.h)

/*
#define ALLOC_DEBUG
#define POOL_DEBUG
#define ALLOC_USE_MALLOC
#define MAKE_TABLE_PROFILE
#define ALLOC_STATS
*/

typedef struct ap_pool_t {
union block_hdr *first;
union block_hdr *last;
struct cleanup *cleanups;
struct process_chain *subprocesses;
struct ap_pool_t *sub_pools;
struct ap_pool_t *sub_next;
struct ap_pool_t *sub_prev;
struct ap_pool_t *parent;
char *free_first_avail;
#ifdef ALLOC_USE_MALLOC
void *allocation_list;
#endif
#ifdef POOL_DEBUG
struct ap_pool_t *joined;
#endif
int (*apr_abort)(int retcode);
struct datastruct *prog_data;
} ap_pool_t;

To enable allocation debugging simply move the #define ALLOC_DEBUG above the start of the comments block and rebuild the server.

Note

In order to use the various options the server must be rebuilt after editing the header file.

developer/documenting.html100644 0 0 10130 11237400230 13377 0ustar 0 0 Documenting Apache 2.0 - Apache HTTP Server
<-
Apache > HTTP Server > Documentation > Version 2.2 > Developer Documentation

Documenting Apache 2.0

Apache 2.0 uses Doxygen to document the APIs and global variables in the code. This will explain the basics of how to document using Doxygen.

top

Brief Description

To start a documentation block, use /**
To end a documentation block, use */

In the middle of the block, there are multiple tags we can use:

Description of this functions purpose
@param parameter_name description
@return description
@deffunc signature of the function

The deffunc is not always necessary. DoxyGen does not have a full parser in it, so any prototype that use a macro in the return type declaration is too complex for scandoc. Those functions require a deffunc. An example (using &gt; rather than >):

/**
 * return the final element of the pathname
 * @param pathname The path to get the final element of
 * @return the final element of the path
 * @tip Examples:
 * <pre>
 * "/foo/bar/gum" -&gt; "gum"
 * "/foo/bar/gum/" -&gt; ""
 * "gum" -&gt; "gum"
 * "wi\\n32\\stuff" -&gt; "stuff"
 * </pre>
 * @deffunc const char * ap_filename_of_pathname(const char *pathname)
 */

At the top of the header file, always include:

/**
 * @package Name of library header
 */

Doxygen uses a new HTML file for each package. The HTML files are named {Name_of_library_header}.html, so try to be concise with your names.

For a further discussion of the possibilities please refer to the Doxygen site.

developer/filters.html100644 0 0 27634 11237400230 12554 0ustar 0 0 How filters work in Apache 2.0 - Apache HTTP Server
<-
Apache > HTTP Server > Documentation > Version 2.2 > Developer Documentation

How filters work in Apache 2.0

Warning

This is a cut 'n paste job from an email (<022501c1c529$f63a9550$7f00000a@KOJ>) and only reformatted for better readability. It's not up to date but may be a good start for further research.

top

Filter Types

There are three basic filter types (each of these is actually broken down into two categories, but that comes later).

CONNECTION
Filters of this type are valid for the lifetime of this connection. (AP_FTYPE_CONNECTION, AP_FTYPE_NETWORK)
PROTOCOL
Filters of this type are valid for the lifetime of this request from the point of view of the client, this means that the request is valid from the time that the request is sent until the time that the response is received. (AP_FTYPE_PROTOCOL, AP_FTYPE_TRANSCODE)
RESOURCE
Filters of this type are valid for the time that this content is used to satisfy a request. For simple requests, this is identical to PROTOCOL, but internal redirects and sub-requests can change the content without ending the request. (AP_FTYPE_RESOURCE, AP_FTYPE_CONTENT_SET)

It is important to make the distinction between a protocol and a resource filter. A resource filter is tied to a specific resource, it may also be tied to header information, but the main binding is to a resource. If you are writing a filter and you want to know if it is resource or protocol, the correct question to ask is: "Can this filter be removed if the request is redirected to a different resource?" If the answer is yes, then it is a resource filter. If it is no, then it is most likely a protocol or connection filter. I won't go into connection filters, because they seem to be well understood. With this definition, a few examples might help:

Byterange
We have coded it to be inserted for all requests, and it is removed if not used. Because this filter is active at the beginning of all requests, it can not be removed if it is redirected, so this is a protocol filter.
http_header
This filter actually writes the headers to the network. This is obviously a required filter (except in the asis case which is special and will be dealt with below) and so it is a protocol filter.
Deflate
The administrator configures this filter based on which file has been requested. If we do an internal redirect from an autoindex page to an index.html page, the deflate filter may be added or removed based on config, so this is a resource filter.

The further breakdown of each category into two more filter types is strictly for ordering. We could remove it, and only allow for one filter type, but the order would tend to be wrong, and we would need to hack things to make it work. Currently, the RESOURCE filters only have one filter type, but that should change.

top

How are filters inserted?

This is actually rather simple in theory, but the code is complex. First of all, it is important that everybody realize that there are three filter lists for each request, but they are all concatenated together. So, the first list is r->output_filters, then r->proto_output_filters, and finally r->connection->output_filters. These correspond to the RESOURCE, PROTOCOL, and CONNECTION filters respectively. The problem previously, was that we used a singly linked list to create the filter stack, and we started from the "correct" location. This means that if I had a RESOURCE filter on the stack, and I added a CONNECTION filter, the CONNECTION filter would be ignored. This should make sense, because we would insert the connection filter at the top of the c->output_filters list, but the end of r->output_filters pointed to the filter that used to be at the front of c->output_filters. This is obviously wrong. The new insertion code uses a doubly linked list. This has the advantage that we never lose a filter that has been inserted. Unfortunately, it comes with a separate set of headaches.

The problem is that we have two different cases were we use subrequests. The first is to insert more data into a response. The second is to replace the existing response with an internal redirect. These are two different cases and need to be treated as such.

In the first case, we are creating the subrequest from within a handler or filter. This means that the next filter should be passed to make_sub_request function, and the last resource filter in the sub-request will point to the next filter in the main request. This makes sense, because the sub-request's data needs to flow through the same set of filters as the main request. A graphical representation might help:

Default_handler --> includes_filter --> byterange --> ...

If the includes filter creates a sub request, then we don't want the data from that sub-request to go through the includes filter, because it might not be SSI data. So, the subrequest adds the following:

    
Default_handler --> includes_filter -/-> byterange --> ...
                                    /
Default_handler --> sub_request_core

What happens if the subrequest is SSI data? Well, that's easy, the includes_filter is a resource filter, so it will be added to the sub request in between the Default_handler and the sub_request_core filter.

The second case for sub-requests is when one sub-request is going to become the real request. This happens whenever a sub-request is created outside of a handler or filter, and NULL is passed as the next filter to the make_sub_request function.

In this case, the resource filters no longer make sense for the new request, because the resource has changed. So, instead of starting from scratch, we simply point the front of the resource filters for the sub-request to the front of the protocol filters for the old request. This means that we won't lose any of the protocol filters, neither will we try to send this data through a filter that shouldn't see it.

The problem is that we are using a doubly-linked list for our filter stacks now. But, you should notice that it is possible for two lists to intersect in this model. So, you do you handle the previous pointer? This is a very difficult question to answer, because there is no "right" answer, either method is equally valid. I looked at why we use the previous pointer. The only reason for it is to allow for easier addition of new servers. With that being said, the solution I chose was to make the previous pointer always stay on the original request.

This causes some more complex logic, but it works for all cases. My concern in having it move to the sub-request, is that for the more common case (where a sub-request is used to add data to a response), the main filter chain would be wrong. That didn't seem like a good idea to me.

top

Asis

The final topic. :-) Mod_Asis is a bit of a hack, but the handler needs to remove all filters except for connection filters, and send the data. If you are using mod_asis, all other bets are off.

top

Explanations

The absolutely last point is that the reason this code was so hard to get right, was because we had hacked so much to force it to work. I wrote most of the hacks originally, so I am very much to blame. However, now that the code is right, I have started to remove some hacks. Most people should have seen that the reset_filters and add_required_filters functions are gone. Those inserted protocol level filters for error conditions, in fact, both functions did the same thing, one after the other, it was really strange. Because we don't lose protocol filters for error cases any more, those hacks went away. The HTTP_HEADER, Content-length, and Byterange filters are all added in the insert_filters phase, because if they were added earlier, we had some interesting interactions. Now, those could all be moved to be inserted with the HTTP_IN, CORE, and CORE_IN filters. That would make the code easier to follow.

developer/hooks.html100644 0 0 24603 11237400230 12220 0ustar 0 0 Apache 2.0 Hook Functions - Apache HTTP Server
<-
Apache > HTTP Server > Documentation > Version 2.2 > Developer Documentation

Apache 2.0 Hook Functions

Warning

This document is still in development and may be partially out of date.

In general, a hook function is one that Apache will call at some point during the processing of a request. Modules can provide functions that are called, and specify when they get called in comparison to other modules.

top

Creating a hook function

In order to create a new hook, four things need to be done:

Declare the hook function

Use the AP_DECLARE_HOOK macro, which needs to be given the return type of the hook function, the name of the hook, and the arguments. For example, if the hook returns an int and takes a request_rec * and an int and is called do_something, then declare it like this:

AP_DECLARE_HOOK(int, do_something, (request_rec *r, int n))

This should go in a header which modules will include if they want to use the hook.

Create the hook structure

Each source file that exports a hook has a private structure which is used to record the module functions that use the hook. This is declared as follows:

APR_HOOK_STRUCT(
APR_HOOK_LINK(do_something)
...
)

Implement the hook caller

The source file that exports the hook has to implement a function that will call the hook. There are currently three possible ways to do this. In all cases, the calling function is called ap_run_hookname().

Void hooks

If the return value of a hook is void, then all the hooks are called, and the caller is implemented like this:

AP_IMPLEMENT_HOOK_VOID(do_something, (request_rec *r, int n), (r, n))

The second and third arguments are the dummy argument declaration and the dummy arguments as they will be used when calling the hook. In other words, this macro expands to something like this:

void ap_run_do_something(request_rec *r, int n)
{
...
do_something(r, n);
}

Hooks that return a value

If the hook returns a value, then it can either be run until the first hook that does something interesting, like so:

AP_IMPLEMENT_HOOK_RUN_FIRST(int, do_something, (request_rec *r, int n), (r, n), DECLINED)

The first hook that does not return DECLINED stops the loop and its return value is returned from the hook caller. Note that DECLINED is the tradition Apache hook return meaning "I didn't do anything", but it can be whatever suits you.

Alternatively, all hooks can be run until an error occurs. This boils down to permitting two return values, one of which means "I did something, and it was OK" and the other meaning "I did nothing". The first function that returns a value other than one of those two stops the loop, and its return is the return value. Declare these like so:

AP_IMPLEMENT_HOOK_RUN_ALL(int, do_something, (request_rec *r, int n), (r, n), OK, DECLINED)

Again, OK and DECLINED are the traditional values. You can use what you want.

Call the hook callers

At appropriate moments in the code, call the hook caller, like so:

int n, ret;
request_rec *r;

ret=ap_run_do_something(r, n);

top

Hooking the hook

A module that wants a hook to be called needs to do two things.

Implement the hook function

Include the appropriate header, and define a static function of the correct type:

static int my_something_doer(request_rec *r, int n)
{
...
return OK;
}

Add a hook registering function

During initialisation, Apache will call each modules hook registering function, which is included in the module structure:

static void my_register_hooks()
{
ap_hook_do_something(my_something_doer, NULL, NULL, APR_HOOK_MIDDLE);
}

mode MODULE_VAR_EXPORT my_module =
{
...
my_register_hooks /* register hooks */
};

Controlling hook calling order

In the example above, we didn't use the three arguments in the hook registration function that control calling order. There are two mechanisms for doing this. The first, rather crude, method, allows us to specify roughly where the hook is run relative to other modules. The final argument control this. There are three possible values: APR_HOOK_FIRST, APR_HOOK_MIDDLE and APR_HOOK_LAST.

All modules using any particular value may be run in any order relative to each other, but, of course, all modules using APR_HOOK_FIRST will be run before APR_HOOK_MIDDLE which are before APR_HOOK_LAST. Modules that don't care when they are run should use APR_HOOK_MIDDLE. (I spaced these out so people could do stuff like APR_HOOK_FIRST-2 to get in slightly earlier, but is this wise? - Ben)

Note that there are two more values, APR_HOOK_REALLY_FIRST and APR_HOOK_REALLY_LAST. These should only be used by the hook exporter.

The other method allows finer control. When a module knows that it must be run before (or after) some other modules, it can specify them by name. The second (third) argument is a NULL-terminated array of strings consisting of the names of modules that must be run before (after) the current module. For example, suppose we want "mod_xyz.c" and "mod_abc.c" to run before we do, then we'd hook as follows:

static void register_hooks()
{
static const char * const aszPre[] = { "mod_xyz.c", "mod_abc.c", NULL };

ap_hook_do_something(my_something_doer, aszPre, NULL, APR_HOOK_MIDDLE);
}

Note that the sort used to achieve this is stable, so ordering set by APR_HOOK_ORDER is preserved, as far as is possible.

Ben Laurie, 15th August 1999

developer/index.html100644 0 0 11314 11237400230 12177 0ustar 0 0 Developer Documentation for Apache 2.0 - Apache HTTP Server
<-
Apache > HTTP Server > Documentation > Version 2.2

Developer Documentation for Apache 2.0

Many of the documents on these Developer pages are lifted from Apache 1.3's documentation. While they are all being updated to Apache 2.0, they are in different stages of progress. Please be patient, and point out any discrepancies or errors on the developer/ pages directly to the dev@httpd.apache.org mailing list.

top

Topics

top

External Resources

developer/modules.html100644 0 0 31174 11237400230 12546 0ustar 0 0 モジュールの Apache 1.3 から Apache 2.0 への移植 - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2 > Developer Documentation

モジュールの Apache 1.3 から Apache 2.0 への移植

この文書は mod_mmap_static モジュールを Apache 2.0 用に移植した時に 学んだ経験をもとに書いた、最初の手引き書です。まだまだ完全じゃないし、 ひょっとすると間違っている部分もあるかもしれませんが、 取っ掛りにはなるでしょう。

top

簡単な変更点

クリーンナップ ルーチン

クリーンナップルーチンは apr_status_t 型である必要があります。 そして、apr_status_t 型の値を返さなくてはなりません。 クリーンナップ中のエラーを通知する必要がなければ、返り値は普通、 ARP_SUCCESS です。たとえエラーを通知したとしても、 すべてのコードがその通知をチェックしたり、 エラーに応じた動作をするわけではないことに気をつけてください。

初期化ルーチン

初期化ルーチンは処理全体から見てしっくりくるような意味を表すように、 名前が変更されました。ですから、mmap_init から mmap_post_config のようにちょっと変更されました。 渡される引数は大幅に変更され、次のようになりました。

データ型

データ型のほとんどは APR に移されました。つまり、 いくつかの名前が前述のように変更されています。 施すべき変更点の簡単な一覧を以下に示します。

top

もっと厄介な変更点…

フックの登録

新しいアーキテクチャでは作成した関数を呼び出すのに 一連のフックを使用します。このフックは、新しい関数 static void register_hooks(void) を使って登録するよう、 モジュールに書き足さなくてはなりません。 この関数は、なにをすべきか一旦理解してしまえば、 十分にわかりやすいものです。 リクエストの処理のあるステージで呼び出さなくてはならない 関数は登録する必要があります。ハンドラは登録する必要はありません。 関数を登録できるフェーズはたくさんあります。 それぞれのフェーズで、関数を呼び出す相対的な順番は、 かなりの程度制御できます。

以下は、mod_mmap_static に追加したコードです:

static void register_hooks(void)
{
    static const char * const aszPre[]={ "http_core.c",NULL };
    ap_hook_post_config(mmap_post_config,NULL,NULL,HOOK_MIDDLE);
    ap_hook_translate_name(mmap_static_xlat,aszPre,NULL,HOOK_LAST);
};

ここでは呼びだすべき二つの関数を登録しています。一つは post_config ステージ用 (ほとんどすべてのモジュール はこれが必要です) で、もう一つは translate_name フェーズ用です。 それぞれの関数は名前は違うけれども形式は同じであることに注意してください。 それでは、形式はどのようになっているでしょうか?

ap_hook_phase_name(function_name, predecessors, successors, position);

三つの位置が定義されています…

位置を定義するには、上記の「位置」を指定し、 修飾子である「先行」と「後行」で手を加えます。 「先行」「後行」は、呼ばれるべき関数のリストです。 「先行」は関数の実行前に呼ばれるもので、 「後行」は実行後に呼ばれるものです。

mod_mmap_static の場合、post_config ステージでは必要ありませんが、 mmap_static_xlat が core モジュールが名前の変換を実行した後に 呼ばれなければなりません。 そこで aszPre を使って HOOK_LAST の修飾子を定義しています。

モジュールの定義

モジュールの定義を作成する際に注意しなければならない ステージの数は激減しています。古い定義は次のようになっていました。

module MODULE_VAR_EXPORT module_name_module =
{
    STANDARD_MODULE_STUFF,
    /* initializer */
    /* dir config creater */
    /* dir merger --- default is to override */
    /* server config */
    /* merge server config */
    /* command handlers */
    /* handlers */
    /* filename translation */
    /* check_user_id */
    /* check auth */
    /* check access */
    /* type_checker */
    /* fixups */
    /* logger */
    /* header parser */
    /* child_init */
    /* child_exit */
    /* post read-request */
};

新しい構造体はとってもシンプルです…

module MODULE_VAR_EXPORT module_name_module =
{
    STANDARD20_MODULE_STUFF,
    /* create per-directory config structures */
    /* merge per-directory config structures  */
    /* create per-server config structures    */
    /* merge per-server config structures     */
    /* command handlers */
    /* handlers */
    /* register hooks */
};

このうちのいくつかは古いものから新しいものに直接読み替えられるもので、 いくつかはそうではありません。どうすればいいのかを要約してみます。

直接読み替えられるステージ:

/* ディレクトリ設定作成関数 */
/* ディレクトリ毎設定構造体作成 */
/* サーバ設定作成関数 */
/* サーバ毎設定構造体作成 */
/* ディレクトリ設定マージ関数 */
/* ディレクトリ毎設定構造体マージ */
/* サーバ設定マージ関数 */
/* サーバ毎設定構造体作成マージ */
/* コマンド・テーブル */
/* コマンド apr_table_t */
/* ハンドラ */
/* ハンドラ */

古い関数の残りのものはフックとして登録されるべきです。 現時点で次のようなフック・ステージが定義されています…

ap_hook_post_config
(以前の _init ルーチンが登録されるべき場所です)
ap_hook_http_method
(リクエストから HTTP メソッドを取得します (互換用))
ap_hook_open_logs
(特定のログのオープン)
ap_hook_auth_checker
(リソースが権限を必要とするかどうかの確認)
ap_hook_access_checker
(モジュール固有の制約の確認)
ap_hook_check_user_id
(ユーザ ID とパスワードの確認)
ap_hook_default_port
(サーバのデフォルト・ポートの取得)
ap_hook_pre_connection
(処理の直前に必要なことを実行。ただし accept 直後に呼ばれる)
ap_hook_process_connection
(プロトコルの処理)
ap_hook_child_init
(子プロセス起動直後)
ap_hook_create_request
(??)
ap_hook_fixups
(応答内容の生成を変更するラスト・チャンス)
ap_hook_handler
(応答内容の生成)
ap_hook_header_parser
(モジュールにヘッダの照会をさせる。ほとんどのモジュールでは使われません。post_read_request を使います)
ap_hook_insert_filter
(フィルタ・チェインにフィルタを挿入)
ap_hook_log_transaction
(リクエストについての情報を記録する)
ap_hook_optional_fn_retrieve
(オプションとして登録された関数の取得)
ap_hook_post_read_request
(リクエストを読みこんだ後、他のフェーズの前に呼ばれる)
ap_hook_quick_handler
リクエストの処理が始まる前に呼ばれる。キャッシュモジュールが 使用している
ap_hook_translate_name
(URI をファイル名に変換する)
ap_hook_type_checker
(文書型の決定と設定。あるいはその片方)
developer/request.html100644 0 0 33157 11237400230 12571 0ustar 0 0 Request Processing in Apache 2.0 - Apache HTTP Server
<-
Apache > HTTP Server > Documentation > Version 2.2 > Developer Documentation

Request Processing in Apache 2.0

Warning

Warning - this is a first (fast) draft that needs further revision!

Several changes in Apache 2.0 affect the internal request processing mechanics. Module authors need to be aware of these changes so they may take advantage of the optimizations and security enhancements.

The first major change is to the subrequest and redirect mechanisms. There were a number of different code paths in Apache 1.3 to attempt to optimize subrequest or redirect behavior. As patches were introduced to 2.0, these optimizations (and the server behavior) were quickly broken due to this duplication of code. All duplicate code has been folded back into ap_process_request_internal() to prevent the code from falling out of sync again.

This means that much of the existing code was 'unoptimized'. It is the Apache HTTP Project's first goal to create a robust and correct implementation of the HTTP server RFC. Additional goals include security, scalability and optimization. New methods were sought to optimize the server (beyond the performance of Apache 1.3) without introducing fragile or insecure code.

top

The Request Processing Cycle

All requests pass through ap_process_request_internal() in request.c, including subrequests and redirects. If a module doesn't pass generated requests through this code, the author is cautioned that the module may be broken by future changes to request processing.

To streamline requests, the module author can take advantage of the hooks offered to drop out of the request cycle early, or to bypass core Apache hooks which are irrelevant (and costly in terms of CPU.)

top

The Request Parsing Phase

Unescapes the URL

The request's parsed_uri path is unescaped, once and only once, at the beginning of internal request processing.

This step is bypassed if the proxyreq flag is set, or the parsed_uri.path element is unset. The module has no further control of this one-time unescape operation, either failing to unescape or multiply unescaping the URL leads to security reprecussions.

Strips Parent and This Elements from the URI

All /../ and /./ elements are removed by ap_getparents(). This helps to ensure the path is (nearly) absolute before the request processing continues.

This step cannot be bypassed.

Initial URI Location Walk

Every request is subject to an ap_location_walk() call. This ensures that <Location> sections are consistently enforced for all requests. If the request is an internal redirect or a sub-request, it may borrow some or all of the processing from the previous or parent request's ap_location_walk, so this step is generally very efficient after processing the main request.

translate_name

Modules can determine the file name, or alter the given URI in this step. For example, mod_vhost_alias will translate the URI's path into the configured virtual host, mod_alias will translate the path to an alias path, and if the request falls back on the core, the DocumentRoot is prepended to the request resource.

If all modules DECLINE this phase, an error 500 is returned to the browser, and a "couldn't translate name" error is logged automatically.

Hook: map_to_storage

After the file or correct URI was determined, the appropriate per-dir configurations are merged together. For example, mod_proxy compares and merges the appropriate <Proxy> sections. If the URI is nothing more than a local (non-proxy) TRACE request, the core handles the request and returns DONE. If no module answers this hook with OK or DONE, the core will run the request filename against the <Directory> and <Files> sections. If the request 'filename' isn't an absolute, legal filename, a note is set for later termination.

URI Location Walk

Every request is hardened by a second ap_location_walk() call. This reassures that a translated request is still subjected to the configured <Location> sections. The request again borrows some or all of the processing from its previous location_walk above, so this step is almost always very efficient unless the translated URI mapped to a substantially different path or Virtual Host.

Hook: header_parser

The main request then parses the client's headers. This prepares the remaining request processing steps to better serve the client's request.

top

The Security Phase

Needs Documentation. Code is:

switch (ap_satisfies(r)) {
case SATISFY_ALL:
case SATISFY_NOSPEC:
    if ((access_status = ap_run_access_checker(r)) != 0) {
        return decl_die(access_status, "check access", r);
    }

    if (ap_some_auth_required(r)) {
        if (((access_status = ap_run_check_user_id(r)) != 0)
            || !ap_auth_type(r)) {
            return decl_die(access_status, ap_auth_type(r)
                          ? "check user.  No user file?"
                          : "perform authentication. AuthType not set!",
                          r);
        }

        if (((access_status = ap_run_auth_checker(r)) != 0)
            || !ap_auth_type(r)) {
            return decl_die(access_status, ap_auth_type(r)
                          ? "check access.  No groups file?"
                          : "perform authentication. AuthType not set!",
                          r);
        }
    }
    break;

case SATISFY_ANY:
    if (((access_status = ap_run_access_checker(r)) != 0)) {
        if (!ap_some_auth_required(r)) {
            return decl_die(access_status, "check access", r);
        }

        if (((access_status = ap_run_check_user_id(r)) != 0)
            || !ap_auth_type(r)) {
            return decl_die(access_status, ap_auth_type(r)
                          ? "check user.  No user file?"
                          : "perform authentication. AuthType not set!",
                          r);
        }

        if (((access_status = ap_run_auth_checker(r)) != 0)
            || !ap_auth_type(r)) {
            return decl_die(access_status, ap_auth_type(r)
                          ? "check access.  No groups file?"
                          : "perform authentication. AuthType not set!",
                          r);
        }
    }
    break;
}
top

The Preparation Phase

Hook: type_checker

The modules have an opportunity to test the URI or filename against the target resource, and set mime information for the request. Both mod_mime and mod_mime_magic use this phase to compare the file name or contents against the administrator's configuration and set the content type, language, character set and request handler. Some modules may set up their filters or other request handling parameters at this time.

If all modules DECLINE this phase, an error 500 is returned to the browser, and a "couldn't find types" error is logged automatically.

Hook: fixups

Many modules are 'trounced' by some phase above. The fixups phase is used by modules to 'reassert' their ownership or force the request's fields to their appropriate values. It isn't always the cleanest mechanism, but occasionally it's the only option.

top

The Handler Phase

This phase is not part of the processing in ap_process_request_internal(). Many modules prepare one or more subrequests prior to creating any content at all. After the core, or a module calls ap_process_request_internal() it then calls ap_invoke_handler() to generate the request.

Hook: insert_filter

Modules that transform the content in some way can insert their values and override existing filters, such that if the user configured a more advanced filter out-of-order, then the module can move its order as need be. There is no result code, so actions in this hook better be trusted to always succeed.

Hook: handler

The module finally has a chance to serve the request in its handler hook. Note that not every prepared request is sent to the handler hook. Many modules, such as mod_autoindex, will create subrequests for a given URI, and then never serve the subrequest, but simply lists it for the user. Remember not to put required teardown from the hooks above into this module, but register pool cleanups against the request pool to free resources as required.

developer/thread_safety.html100644 0 0 36007 11237400230 13720 0ustar 0 0 Apache 2.0 Thread Safety Issues - Apache HTTP Server
<-
Apache > HTTP Server > Documentation > Version 2.2 > Developer Documentation

Apache 2.0 Thread Safety Issues

When using any of the threaded mpms in Apache 2.0 it is important that every function called from Apache be thread safe. When linking in 3rd party extensions it can be difficult to determine whether the resulting server will be thread safe. Casual testing generally won't tell you this either as thread safety problems can lead to subtle race conditons that may only show up in certain conditions under heavy load.

top

Global and static variables

When writing your module or when trying to determine if a module or 3rd party library is thread safe there are some common things to keep in mind.

First, you need to recognize that in a threaded model each individual thread has its own program counter, stack and registers. Local variables live on the stack, so those are fine. You need to watch out for any static or global variables. This doesn't mean that you are absolutely not allowed to use static or global variables. There are times when you actually want something to affect all threads, but generally you need to avoid using them if you want your code to be thread safe.

In the case where you have a global variable that needs to be global and accessed by all threads, be very careful when you update it. If, for example, it is an incrementing counter, you need to atomically increment it to avoid race conditions with other threads. You do this using a mutex (mutual exclusion). Lock the mutex, read the current value, increment it and write it back and then unlock the mutex. Any other thread that wants to modify the value has to first check the mutex and block until it is cleared.

If you are using APR, have a look at the apr_atomic_* functions and the apr_thread_mutex_* functions.

top

errno

This is a common global variable that holds the error number of the last error that occurred. If one thread calls a low-level function that sets errno and then another thread checks it, we are bleeding error numbers from one thread into another. To solve this, make sure your module or library defines _REENTRANT or is compiled with -D_REENTRANT. This will make errno a per-thread variable and should hopefully be transparent to the code. It does this by doing something like this:

#define errno (*(__errno_location()))

which means that accessing errno will call __errno_location() which is provided by the libc. Setting _REENTRANT also forces redefinition of some other functions to their *_r equivalents and sometimes changes the common getc/putc macros into safer function calls. Check your libc documentation for specifics. Instead of, or in addition to _REENTRANT the symbols that may affect this are _POSIX_C_SOURCE, _THREAD_SAFE, _SVID_SOURCE, and _BSD_SOURCE.

top

Common standard troublesome functions

Not only do things have to be thread safe, but they also have to be reentrant. strtok() is an obvious one. You call it the first time with your delimiter which it then remembers and on each subsequent call it returns the next token. Obviously if multiple threads are calling it you will have a problem. Most systems have a reentrant version of of the function called strtok_r() where you pass in an extra argument which contains an allocated char * which the function will use instead of its own static storage for maintaining the tokenizing state. If you are using APR you can use apr_strtok().

crypt() is another function that tends to not be reentrant, so if you run across calls to that function in a library, watch out. On some systems it is reentrant though, so it is not always a problem. If your system has crypt_r() chances are you should be using that, or if possible simply avoid the whole mess by using md5 instead.

top

Common 3rd Party Libraries

The following is a list of common libraries that are used by 3rd party Apache modules. You can check to see if your module is using a potentially unsafe library by using tools such as ldd(1) and nm(1). For PHP, for example, try this:

% ldd libphp4.so
libsablot.so.0 => /usr/local/lib/libsablot.so.0 (0x401f6000)
libexpat.so.0 => /usr/lib/libexpat.so.0 (0x402da000)
libsnmp.so.0 => /usr/lib/libsnmp.so.0 (0x402f9000)
libpdf.so.1 => /usr/local/lib/libpdf.so.1 (0x40353000)
libz.so.1 => /usr/lib/libz.so.1 (0x403e2000)
libpng.so.2 => /usr/lib/libpng.so.2 (0x403f0000)
libmysqlclient.so.11 => /usr/lib/libmysqlclient.so.11 (0x40411000)
libming.so => /usr/lib/libming.so (0x40449000)
libm.so.6 => /lib/libm.so.6 (0x40487000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x404a8000)
libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x404e7000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x40505000)
libssl.so.2 => /lib/libssl.so.2 (0x40532000)
libcrypto.so.2 => /lib/libcrypto.so.2 (0x40560000)
libresolv.so.2 => /lib/libresolv.so.2 (0x40624000)
libdl.so.2 => /lib/libdl.so.2 (0x40634000)
libnsl.so.1 => /lib/libnsl.so.1 (0x40637000)
libc.so.6 => /lib/libc.so.6 (0x4064b000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)

In addition to these libraries you will need to have a look at any libraries linked statically into the module. You can use nm(1) to look for individual symbols in the module.

top

Library List

Please drop a note to dev@httpd.apache.org if you have additions or corrections to this list.

LibraryVersionThread Safe?Notes
ASpell/PSpell ?
Berkeley DB 3.x, 4.x Yes Be careful about sharing a connection across threads.
bzip2 Yes Both low-level and high-level APIs are thread-safe. However, high-level API requires thread-safe access to errno.
cdb ?
C-Client Perhaps c-client uses strtok() and gethostbyname() which are not thread-safe on most C library implementations. c-client's static data is meant to be shared across threads. If strtok() and gethostbyname() are thread-safe on your OS, c-client may be thread-safe.
cpdflib ?
libcrypt ?
Expat Yes Need a separate parser instance per thread
FreeTDS ?
FreeType ?
GD 1.8.x ?
GD 2.0.x ?
gdbm No Errors returned via a static gdbm_error variable
ImageMagick 5.2.2 Yes ImageMagick docs claim it is thread safe since version 5.2.2 (see Change log).
Imlib2 ?
libjpeg v6b ?
libmysqlclient Yes Use mysqlclient_r library variant to ensure thread-safety. For more information, please read http://www.mysql.com/doc/en/Threaded_clients.html.
Ming 0.2a ?
Net-SNMP 5.0.x ?
OpenLDAP 2.1.x Yes Use ldap_r library variant to ensure thread-safety.
OpenSSL 0.9.6g Yes Requires proper usage of CRYPTO_num_locks, CRYPTO_set_locking_callback, CRYPTO_set_id_callback
liboci8 (Oracle 8+) 8.x,9.x ?
pdflib 5.0.x Yes PDFLib docs claim it is thread safe; changes.txt indicates it has been partially thread-safe since V1.91: http://www.pdflib.com/products/pdflib/index.html.
libpng 1.0.x ?
libpng 1.2.x ?
libpq (PostgreSQL) 7.x Yes Don't share connections across threads and watch out for crypt() calls
Sablotron 0.95 ?
zlib 1.1.4 Yes Relies upon thread-safe zalloc and zfree functions Default is to use libc's calloc/free which are thread-safe.
dns-caveats.html100644 0 0 33312 11237400230 11315 0ustar 0 0 DNS と Apache にまつわる注意事項 - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2

DNS と Apache にまつわる注意事項

This translation may be out of date. Check the English version for recent changes.

本文書の内容は次の一言に尽きます。「Apache が設定ファイルを読み込むときに DNS を使用する必要がないようにして下さい」。Apache が設定ファイルを 読み込むときに DNS を使用する必要がある場合、信頼性の問題 (起動しないかもしれません) やサービス拒否や盗用アタック (他のユーザからヒットを盗むことを含みます) の問題に直面するかもしれません。

top

簡単な例

<VirtualHost www.abc.dom>
ServerAdmin webgirl@abc.dom
DocumentRoot /www/abc
</VirtualHost>

Apache が正常に機能するには、バーチャルホスト毎に必ず二つの 情報が必要になります。それは、 ServerName と、そのサーバが応答するための IP (最低一つ) です。 上記例では IP アドレスを含んでいませんので、Apache は DNS を使用して www.abc.dom を見つけなければなりません。 何らかの理由で設定ファイルを読み込んでいるときに DNS が利用できなかった場合、 バーチャルホストは設定されません。 そして、そのバーチャルホストに対するヒットには応答がなされません (Apache 1.2 以前では起動すらしません)。

www.abc.dom のアドレスが 192.0.2.1 だとします。では、次の設定について考えてみましょう。

<VirtualHost 192.0.2.1>
ServerAdmin webgirl@abc.dom
DocumentRoot /www/abc
</VirtualHost>

現在のリリースでは Apache は DNS 逆引きを使用して このバーチャルホストの ServerName を見つけます。 その逆引きが失敗した場合は部分的にバーチャルホストを無効にします (Apache 1.2 より前では起動すらしません)。 バーチャルホストが名前ベースであれば完全に無効になりますが、 IP ベースであれば概ね動作します。しかしながら、サーバ名を 含む完全な URL を生成しなければならない場合は、正しい URL の生成ができません。

次の例は上記の問題を解決しています。

<VirtualHost 192.0.2.1>
ServerName www.abc.dom
ServerAdmin webgirl@abc.dom
DocumentRoot /www/abc
</VirtualHost>

top

サービス拒否

サービス拒否が起こる場合、(少なくとも) 二つのケースがあります。 Apache 1.2 より前を実行している場合、バーチャルホストのための 上記の二つの DNS 検索のうち一つ失敗すれば起動すらしません。 そしてこの DNS 検索が自分の制御下にすらない場合もありえます。 例えば、abc.dom が顧客のサーバの一つで、 DNS は顧客自身で管理している場合、単に www.abc.dom レコードを削除するだけで、 (1.2 より前の) サーバを起動不能にすることができます。

もう一つのケースは、より気付きにくいものです。 次の設定について考えてみましょう。

<VirtualHost www.abc.dom>
  ServerAdmin webgirl@abc.dom
  DocumentRoot /www/abc
</VirtualHost>

<VirtualHost www.def.dom>
  ServerAdmin webguy@def.dom
  DocumentRoot /www/def
</VirtualHost>

192.0.2.1 を www.abc.dom に、 192.0.2.2 を www.def.dom に割り当てているとします。 また、def.dom は顧客自身の DNS の制御下にあるとします。この設定で、abc.dom に向けられたトラフィック全てを奪うことができる位置に def.dom を設置できています。後は単に www.def.dom が 192.0.2.1 を参照するように 設定するだけです。DNS は顧客側の DNS でコントロールされているので、 www.def.dom レコードが好きな場所を指すように 設定できてしまうのを止めさせることができません。

192.0.2.1 に対するリクエスト (http://www.abc.dom/whatever 形式の URL を入力したユーザからのもの全てを含みます) は、def.dom バーチャルホストで応答されます。 このようなことが何故起こるかもっと良く知るためには、 応答の必要なバーチャルホストへのリクエストに対して、 Apache がどのように整合性を確保するかについて、 深い議論が必要になります。おおざっぱな説明はこちらに記述されています。

top

「主サーバ」アドレス

Apache 1.1 での 名前ベースのバーチャルホストのサポート 追加の際に、 Apache は httpd の実行されているホストの IP アドレスを知る必要が出てきました。このアドレスを得るために、 (もしあれば) グローバルな ServerName を使用するか、 C 言語の関数 gethostname (コマンドプロンプトで hostname とタイプしたときと同じものを返します) を呼び出すかをします。 その後、得られたアドレスで DNS 検索を行ないます。 現在のところ、この DNS 検索を回避する方法はありません。

DNS サーバがダウンして、この検索ができない事態が起こることを 恐れているのであれば、/etc/hosts にホスト名を記述しておくことができます (マシンが正常に起動するように既に設定されているかもしれません)。 その場合、DNS 参照が失敗した場合にマシンが /etc/hosts を使用するように設定していることを確認してください。 その方法は、どの OS を使用しているかに依存しますが、 /etc/resolv.conf/etc/nsswitch.conf を編集することで設定できます。

もし他の理由で DNS を利用する必要がない場合は、 HOSTRESORDER 環境変数を「 local 」に設定することでそのようにできます。以上これらの事柄は、どんな OS 、レゾルバライブラリを使用しているかに依存します。また、 mod_env を使用して環境変数を制御しない限り、 CGI にも影響を与えます。man ページや使用している OS の FAQ で調べると良いでしょう。

top

以上の問題を解決する方法

top

付録: 将来的な方向性

DNS に関して、現状は全く宜しくありません。Apache 1.2 で、 DNS のイベントが失敗しても少なくとも起動プロセスが続くようにしましたが、 これが最高の解決方法ではないでしょう。アドレスの再割り当てが必要不可避 となっている今日のインターネットにおいては、 設定ファイルの中で明示的な IP アドレスを要求する仕様は、 全く宜しくありません。

盗用のサービスアタックに関して行なうべき事は、 DNS 順引きを行なって得られたアドレスに対する DNS 逆引きを行なって、二つの名前を比較することです。 この二つが一致しなければバーチャルホストは無効になるようにします。 こうするためには逆引き DNS が適切に設定されている必要があります (FTP サーバや TCP ラッパーのおかげで「二重逆引き」DNS は一般的に なっていますので、管理者にはお馴染みものでしょう)。

IP アドレスが使用されていなくて DNS が失敗した場合は、 どうしてもバーチャルホストウェブサーバを信頼性を確保して 起動させることは不可能のようです。 設定の一部を無効にするというような部分的な解決では、 サーバが何をするようにするかにもよりますが、 そのサーバが起動しないより確実に悪い状況になるでしょう。

HTTP/1.1 が開発され、ブラウザやプロキシが Host ヘッダを発行するようになったので、IP ベースのバーチャルホストを 全く使用しなくても済むようになるかもしれません。 この場合、ウェブサーバは設定中に DNS 参照をしなくても済みます。 しかし 1997 年 3 月時点の状況では、 商用レベルのウェブサーバで使用できるほどには、 これらの機能は広く開発が進んでいません。

dso.html100644 0 0 47412 11237400230 7700 0ustar 0 0 動的共有オブジェクト (DSO) サポート - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2

動的共有オブジェクト (DSO) サポート

This translation may be out of date. Check the English version for recent changes.

Apache HTTP サーバはモジュール化されたプログラムで、 管理者がモジュールを選択することでサーバに組み込む機能を選ぶことができます。 モジュールはサーバがビルドされるときに httpd バイナリに 静的に組み込むことができます。もしくは、httpd バイナリとは 別に存在する動的共有オブジェクト (訳注: Dynamic Shared Object) (DSO) としてコンパイルすることも できます。DSO モジュールはサーバがビルドされるときにコンパイルしたり、 Apache 拡張ツール (apxs) を 使って後でコンパイルして追加したりできます。

この文書は DSO モジュールの使い方と、仕組みについて 説明します。

top

実装

個々の Apache モジュールをロードするための DSO サポートは mod_so.c というモジュールの機能に基づいています。 このモジュール は Apache のコアに静的に組み込まれている必要があります。 それは core.c 以外では DSO にできない唯一の モジュールです。事実上、他のすべての Apache のモジュールは、 インストールの文書で説明されているように、 configure--enable-module=shared オプションでそれぞれを DSO ビルドにすることにより、DSO モジュールにすることができます。 mod_foo.so のような DSO にモジュールがコンパイルされれば、 httpd.conf ファイル中で mod_soLoadModule ディレクティブを使うことでサーバの起動や再起動時にこのモジュールを ロードするようにできます。

Apache モジュール用の (特にサードパーティモジュールの) DSO ファイルの 作成を簡単にするために、apxs (APache eXtenSion) という新しいサポートプログラムがあります。 Apache のソースツリーの外で DSO モジュールをビルドするために 使うことができます。発想は単純です: Apache のインストール時の configuremake install のときに Apache の C ヘッダをインストールし、DSO ビルド用のプラットフォーム依存の コンパイラとリンカのフラグを apxs プログラムに追加します。 これにより、ユーザが Apache の配布ソースツリーなしで、さらに DSO サポートのためのプラットフォーム依存のコンパイラやリンカの フラグをいじることなく Apache のモジュールのソースをコンパイル できるようになります。

top

使用法の概要

Apache 2.2 の DSO 機能の概略を知ることができるための、 短く簡潔な概要です:

  1. 配布されている Apache モジュール、仮に mod_foo.c として、それを DSO mod_foo.so にビルド、インストール:

    $ ./configure --prefix=/path/to/install --enable-foo=shared
    $ make install

  2. サードパーティ Apache モジュール、仮に mod_foo.c として、それを DSO mod_foo.so にビルド、インストール:

    $ ./configure --add-module=module_type:/path/to/3rdparty/mod_foo.c \
    --enable-foo=shared
    $ make install

  3. 共有モジュールの 後々のインストール のために Apache を設定:

    $ ./configure --enable-so
    $ make install

  4. サードパーティ Apache モジュール、仮に mod_foo.c として、それを apxs を使って Apache ソースツリーの外で DSO にビルド、インストール:

    $ cd /path/to/3rdparty
    $ apxs -c mod_foo.c
    $ apxs -i -a -n foo mod_foo.la

どの場合においても、共有モジュールをコンパイルした後で、 httpd.confLoadModule ディレクティブを使って Apache がモジュールを使用するように しなければなりません。

top

背景

最近の Unix 系の OS には 動的共有オブジェクト (DSO) の動的リンク/ロードという気のきいた機構が 存在します。これは、実行時にプログラムのアドレス空間に ロードできるような特別な形式でプログラムをビルドすることを 可能にします。

このロードは二つの方法で行なうことができます: 実行プログラムが 起動されたときに ld.so というシステムプログラム により自動的に行なわれる方法と、実行プログラム中から、システムコール dlopen()/dlsym() による Unix ローダへの プログラムシステムのインタフェースを使って手動で行なう方法とが あります。

最初の方法では DSO は普通は共有ライブラリDSO ライブラリ と呼ばれていて、DSO の名前は libfoo.solibfoo.so.1.2 のようになっています。 これらはシステムディレクトリ (通常 /usr/lib) に存在し、 実行プログラムへのリンクはビルド時に -lfoo をリンカに 指定することで確立されます。これによりライブラリへの参照が実行プログラムの ファイルに書き込まれて、起動時に Unix のローダが /usr/lib や、 リンカの -R のようなオプションによりハードコードされたパス、 環境変数 LD_LIBRARY_PATH により設定されたパス、の中から libfoo.so の場所を見つけることができます。それから、 実行プログラム中の (まだ未解決の) シンボルを DSO にあるシンボルで 解決します。

普通は実行プログラム中のシンボルは DSO からは参照されません (DSO は一般的なコードによる再利用可能なライブラリですので)。 ですから、さらなるシンボルの解決は必要ありません。 シンボルは Unix ローダにより完全な解決が行なわれますので、実行ファイル自身は 何もする必要がありません。(実際のところ、静的でない方法でリンクされている すべての実行プログラムに組み込まれている開始用のコードの一部に ld.so を起動するコードが含まれています)。よく使われる ライブラリの動的ロードの利点は明らかです。ライブラリのコードは システムライブラリに libc.so のようにして一度保存するだけでよく、 プログラムのために必要なディスクの領域を節約することができます。

二つめの方法では DSO は普通は共有オブジェクトDSO ファイルと呼ばれていて、任意の拡張子を付けることができます (ただし、標準的な名前は foo.so です)。 これらのファイルは通常はプログラム専用のディレクトリに置かれ、 これらを使う実行プログラムへのリンクは自動的にはされません。 ですので、実行プログラムは dlopen() を使って 実行時に手動で DSO をプログラムのアドレス空間にロードする必要があります。 この時点では実行プログラムに対して DSO のシンボルの解決は行なわれません。 しかし、その代わりに Unix のローダが DSO の (まだ未解決の) シンボルを 実行プログラムによりエクスポートされたシンボルと既にロードされた DSO ライブラリによりエクスポートされたシンボル (特に、どこにでもある libc.so のすべてのシンボル) で自動的に解決します。 こうすることで、DSO は最初から静的にリンクされていたかのように、 実行プログラムのシンボルを知ることができます。

最後に、DSO の API を利点を生かすために、プログラムは 後でディスパッチテーブルなどでシンボルを使うことができるように、 dlsym() を使っていくつかのシンボルを解決します。 すなわち: 実行プログラムは必要なすべてのシンボルを手動で解決しなければ なりません。この機構の利点はプログラムのオプショナルな部分は 必要になるまでロードする必要がない (だからメモリも消費しない) ことです。必要ならば、基本プログラムの機能を拡張するために これらの部分を動的にロードすることができます。

この DSO 機構は簡単なように見えますが、少なくとも一つ難しい点が あります: プログラムを拡張するために DSO を使っているときに、 DSO が実行プログラムからシンボルを解決する点です (二番目の方法)。 これはなぜでしょうか。それは、DSO のシンボルを実行プログラムの シンボルから「逆解決」するというのはライブラリの設計 (ライブラリはそれを使用するプログラムのことは何も 知らない) に反していて、この機能はすべてのプラットフォームに あるわけではなく、標準化もされていないからです。 実際には実行プログラムのグローバルなシンボルは再エクスポートされることは あまりなく、DSO から使うことができません。リンカにグローバルシンボルすべてを エクスポートするようにさせる方法を見つけることが、実行時にプログラムを 拡張するために DSO を使うときの一番の問題です。

共有ライブラリのアプローチが普通の方法です。DSO 機構はそのために 設計されたものですから。したがって、その方法はオペレーティングシステムが 提供するほとんどすべての種類のライブラリで使われています。 一方、プログラムの拡張のために共有オブジェクトを使用する、という方は あまり使われていません。

1998 年の時点で、実行時に実際に機能拡張のために DSO 機構を使っている ソフトウェアパッケージは少しだけでした: Perl 5 (XS 機構と DnaLoader モジュール によるもの)、Netscape サーバなどです。Apache はすでに モジュールの概念を使って機能拡張をしていて、内部的にディスパッチリストに 基づいた外部モジュールの Apache コア機能へのリンクを行なっていましたので、 バージョン 1.3 から、Apache も DSO 機構を使う仲間になりました。 Apache は実行時に DSO を使ってモジュールをロードするようにすでに 運命付けられていたのです。

top

利点と欠点

上記の DSO に基づいた機能は以下の利点があります:

DSO には以下の欠点があります:

env.html100644 0 0 63115 11237400230 7701 0ustar 0 0 Apache の環境変数 - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2

Apache の環境変数

This translation may be out of date. Check the English version for recent changes.

Apache HTTP サーバは環境変数と呼ばれる、名前のついた 変数に情報を記憶する仕組みを提供しています。この情報はログ収集や アクセス制御などのいろいろな操作を制御するために使うことができます。 これらの変数は CGI スクリプトなどの外部プログラムと通信するためにも 使われます。この文書はそれらの変数の操作方法と使用方法をいくつか 紹介します。

これらの変数は環境変数と呼ばれていますが、オペレーティング システムによって制御されている環境変数と同じではありません。 実際は、これらの変数は Apache の内部構造の中に記憶され、操作されています。 それらは、CGI や SSI スクリプトに渡されたときだけ、実際の オペレーティングシステムの環境変数になります。サーバ自身が 実行されているオペレーティングシステムの環境を操作したい場合は、 オペレーティングシステムのシェルが提供している標準の環境変数の 操作方法を使わなければなりません。

top

環境変数の設定

基本的な環境の操作

Apache において環境変数を設定する一番基本的な方法は、 無条件に環境変数を設定する SetEnv ディレクティブを使用することです。 PassEnv ディレクティブにより、Apache が起動されたシェルの 環境変数を渡すこともできます。

リクエスト毎に条件に基づいて設定する

より柔軟性を高めるために、mod_setenvif で提供されているディレクティブを使用することで、リクエストの 特性に基づいて環境変数を設定することができます。例えば、特定のブラウザ (User-Agent) のリクエストや特定の Referer [意図的な綴りです] (訳注: 正しい綴りは referrer ですが、HTTP の仕様では Referer となっています) ヘッダが見つかったときのみ変数を設定することができます。 mod_rewrite の RewriteRule ディレクティブにおいて環境変数を設定する [E=...] オプションを使用することで、 より柔軟な設定を行なうことができます。

一意な識別子

mod_unique_id は、非常に限られた条件の下で 「すべて」のリクエストについて、一意であることが保証されている値を環境変数 UNIQUE_ID に設定します。

標準 CGI 変数

Apache の設定ファイルで設定された環境変数とシェルから渡される 環境変数に加えて、CGI スクリプトと SSI ページには CGI の仕様で要求されている、 リクエストのメタ情報を持った環境変数の組が提供されます。

いくつかの注意

top

環境変数の使用

CGI スクリプト

環境変数の主な利用法の一つは、CGI スクリプトに情報を伝えることです。 上で説明されているように、CGI スクリプトに渡される環境変数は Apache の設定により設定される変数に加えて、リクエストの標準のメタ情報を含んでいます。 詳細は CGI チュートリアル を参照してください。

SSI ページ

mod_include の INCLUDES フィルタで処理される server-parsed (SSI) ドキュメントでは、echo 要素を使用すると環境変数が出力されます。 また、ページのある部分がリクエストの性質に応じて変更されるように、 環境変数をフロー制御要素で使うことができます。詳細は SSI チュートリアル を参照してください。

アクセス制御

allow from env= ディレクティブと deny from env= ディレクティブを使用して、サーバへのアクセスを環境変数の値で制御することができます。 SetEnvIf ディレクティブと組み合わせることで、クライアントの特性に基づいて サーバへのアクセス制御を柔軟に行なうことができるようになります。 たとえば、これらのディレクティブを使用して、特定のブラウザ (User-Agent) からのアクセスを拒否することができます。

条件付きログ記録

LogFormat ディレクティブのオプション %e を使用することで、環境変数をアクセスログに記録することができます。さらに、 CustomLog ディレクティブの条件分岐式を使用することで、 環境変数の値によってリクエストをログに記録するかどうかを決めることができます。 SetEnvIf ディレクティブと組み合わせることで、 どのリクエストをログに記録するかを柔軟に制御することが可能になります。たとえば、 gif で終わるファイル名へのリクエストはログに記録しない、 違うサブネットのクライアントからのリクエストだけをログに記録する、 という選択が可能です。

条件付き応答ヘッダ

Header ディレクティブは環境変数の存在や不在によってクライアントへの応答に特定の HTTP ヘッダを付けるかどうかを決めることができます。 これにより、たとえば、クライアントからのリクエスト にあるヘッダがある場合にのみ特定の応答ヘッダを送る、というようなことが できます。

外部フィルタの適用

ExtFilterDefine ディレクティブを使用して mod_ext_filter で設定される外部フィルタは、 disableenv=enableenv= オプションを使って、環境変数による条件付き適用ができます。

URL の書き換え

RewriteCond ディレクティブで評価文字列として %{ENV:...} 式を指定することで、mod_rewrite の書き換えエンジンが環境変数に基いて条件分岐を行なうことができます。 mod_rewrite が使用可能な変数で ENV: が前についていない変数は、 実際は環境変数ではないということに注意してください。 それらは他のモジュールからは使用できない mod_rewrite 用の特別な変数です。

top

特別な目的の環境変数

互換性の問題を解決するために、特定のクライアントと通信しているときは Apache の動作を変更できる機構が導入されました。できるだけ柔軟にするために、 これらの機構は環境変数を定義することで呼び出されます。普通は、 BrowserMatch ディレクティブを使いますが、たとえば SetEnv ディレクティブや PassEnv ディレクティブも使用することができます。

downgrade-1.0

これを指定することで、リクエストが HTTP/1.0 より新しいプロトコルの場合でも、HTTP/1.0 として扱われます。

force-gzip

DEFLATE フィルタが使用するように設定されているときに、 この環境変数はブラウザの accept-encoding の設定を無視して常に 圧縮された出力を送るようにします。

force-no-vary

応答ヘッダがクライアントに送られる前に Vary フィールドを取り除きます。 クライアントの中にはこのフィールドを正しく解釈しないものがあります。 この変数を設定することでその問題を回避することができます。 この変数を設定すると、force-response-1.0 が設定されたことになります。

force-response-1.0

これが設定されていると、HTTP/1.0 リクエストを発行するクライアントに対しては 常に HTTP/1.0 で応答するようになります。この機能は、 元々は AOL のプロキシの問題のために実装されました。HTTP/1.0 クライアントの中には、 HTTP/1.1 の応答を返されると正しく動作しないものがあるかもしれません。 この機能を使用することで、そのようなクライアントとの間の互換性問題を解決できます。

gzip-only-text/html

これが 1 に設定されると、この変数は text/html 以外のコンテントタイプに対する、mod_deflate 提供の DEFLATE 出力フィルタを無効にします。 また、静的に、既に圧縮されたファイルを使用したい場合、 (gzip だけでなく、"identity" と異なる全てのエンコードに対して) mod_negotiation も変数を評価します。

no-gzip

セットされると、mod_deflateDEFLATE フィルタがオフになります。 そして mod_negotiation はエンコードされたリソースを送らないようにします。

nokeepalive

これが設定されている場合は、KeepAlive を使用しないようにします。

prefer-language

mod_negotiation の挙動に影響を与えます。 (en, ja, x-klingonといった) 言語タグが格納されていれば、その言語の variant を送信しようとします。 そのような variant がない場合は、 通常のネゴシエーション処理が 適用されます。

redirect-carefully

これはクライアントへのリダイレクトの送信をサーバがより注意深く 行なうようにします。 これは通常、リダイレクトに際してクライアントに 問題があることが分かっている場合に使われます。この機能は元々は マイクロソフトのウェブフォルダのソフトが DAV メソッドによるディレクトリのリソースへのリダイレクトの扱いに 問題がり、それを回避するために実装されました。

suppress-error-charset

Apache 2.2 以降で利用可能

クライアントのリクエストに対する応答としてリダイレクトを送信する際、 レスポンスにはリダイレクトが自動的に行なえない (行なわれない) 場合に表示するテキストが含まれます。 通常、このテキストに合致したキャラクタセット、ISO-8859-1 でラベル付けをします。

しかし、リダイレクト先が別の文字セットを使っている場合、 ある問題のあるブラウザのバージョンでは、 リダイレクト先の実際の文字セットの代わりに、 リダイレクト元の文字セットを使ってしまうことがあります。 その結果、例えば変な描画が行なわれたりして、読めなくなったりします。

この環境変数を設定することで、リダイレクションテキストに対する キャラクタセットの指定を除去しますので、それら問題のあるブラウザでも リダイレクト先の文字セットを正しく使うようにできます。

force-proxy-request-1.0, proxy-nokeepalive, proxy-sendchunked, proxy-sendcl

これらの指示子は mod_proxy の挙動を変更します。 詳細は mod_proxy のドキュメントをご参照ください。

top

おかしな挙動をするクライアントに対してプロトコルの動作を変更する

クライアントに関する既知の問題に対処するために、以下の行を httpd.conf に入れることを推奨しています。

古いバージョンの Apache では、クライアントの問題に対応するために httpd.conf に次の行を加えるよう推奨されていましたが、 今となっては、問題としていたクライアントは実際には見かけることは なくなってきたので、この設定はもはや必要ないかもしれません。

#
# The following directives modify normal HTTP response behavior.
# The first directive disables keepalive for Netscape 2.x and browsers that
# spoof it. There are known problems with these browser implementations.
# The second directive is for Microsoft Internet Explorer 4.0b2
# which has a broken HTTP/1.1 implementation and does not properly
# support keepalive when it is used on 301 or 302 (redirect) responses.
#
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0

#
# The following directive disables HTTP/1.1 responses to browsers which
# are in violation of the HTTP/1.0 spec by not being able to grok a
# basic 1.1 response.
#
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0

画像へのリクエストをアクセスログに記録しない

この例では、画像へのリクエストがアクセスログに現れないようにします。 これを変更することで、特定のディレクトリのログ収集をやめたり、 特定のホストからのリクエストのログ収集をやめたりすることが簡単にできます。

SetEnvIf Request_URI \.gif image-request
SetEnvIf Request_URI \.jpg image-request
SetEnvIf Request_URI \.png image-request
CustomLog logs/access_log common env=!image-request

「画像の盗用」を防ぐ

この例は、別のサーバにいる人が、あなたのサーバにある画像を inline 画像として使用することを防ぎます。 これは推奨されている設定ではありませんが、ある限定された状況では有効です。 ここでは、すべての画像は /web/images というディレクトリにあると仮定します。

SetEnvIf Referer "^http://www.example.com/" local_referal
# Allow browsers that do not send Referer info
SetEnvIf Referer "^$" local_referal
<Directory /web/images>
   Order Deny,Allow
   Deny from all
   Allow from env=local_referal
</Directory>

この手法に関する詳しい情報は ApacheToday のチュートリアル「Keeping Your Images from Adorning Other Sites 」を参照してください。

faq/index.html100644 0 0 14103 11237400230 10760 0ustar 0 0 Frequently Asked Questions - Apache HTTP Server
<-
Apache > HTTP Server > Documentation > Version 2.2

Frequently Asked Questions

This document is not a traditional FAQ, but rather a quick guide showing you what to do when you run into problems with the Apache HTTP Server.

A more traditional but quite outdated document is the Apache 1.3 FAQ.

top

"Why can't I ...? Why won't ... work?" What to do in case of problems

If you are having trouble with your Apache server software, you should take the following steps:

Check the ErrorLog!

Apache tries to be helpful when it encounters a problem. In many cases, it will provide some details by writing one or more messages to the server error log. Sometimes this is enough for you to diagnose and fix the problem yourself (such as file permissions or the like). The default location of the error log is /usr/local/apache2/logs/error_log, but see the ErrorLog directive in your config files for the location on your server.

If you end up in any of the support forums this is quite likely to be the first place they will ask you retrieve information from. Please ensure you know where to find your errorlog. If you are unsure, the wiki page here can give you some ideas where to look.

Consult the wiki
The Apache HTTP Server Wiki contains guides to solving many common problems.
Check the Apache bug database
Most problems that get reported to The Apache Group are recorded in the bug database. Do not submit a new bug report until you have checked existing reports (open and closed) and asked about your problem in a user-support forum (see below). If you find that your issue has already been reported, please don't add a "me, too" report.
Ask in a user support forum

Apache has an active community of users who are willing to share their knowledge. Participating in this community is usually the best and fastest way to get answers to your questions and problems.

Users mailing list

#apache on Freenode IRC is also available for user support issues.

Please use the bug database for bugs!

If you've gone through those steps above that are appropriate and have obtained no relief, then please do let the httpd developers know about the problem by logging a bug report.

If your problem involves the server crashing and generating a core dump, please include a backtrace (if possible).

top

Whom do I contact for support?

With millions of users and fewer than sixty volunteer developers, we cannot provide personal support for Apache. For free support, we suggest participating in a user forum (see above).

Professional, commercial support for Apache is available from a number of companies.

filter.html100644 0 0 24765 11237400230 10406 0ustar 0 0 フィルタ - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2

フィルタ

Apache でのフィルタの使い方について記述しています。

top

Apache 2 のフィルタ

Apache 2.0 以降ではフィルタチェイン機能が使え、データが どこから来るかに関わらず、非常に柔軟で調整しやすい方法で 入出力データを処理できます。 入力データをプリプロセスしたり出力データをポストプロセスしたりできます。 この処理は、これまでのリクエスト処理フェーズとは根本的に独立した 処理になります。

Filters can be chained, in a Data Axis orthogonal to request processing

Apache の標準的なディストリビューションでのフィルタ例は :

チャンキングやバイトレンジ処理といった処理を行うために Apache は、内部的にいくつかのフィルタを使っています。

様々なアプリケーションがサードパーティ製のフィルタモジュールとして 実装されていて、modules.apache.org などから取得できます。たとえば :

top

スマートフィルタ

Smart filtering applies different filter providers according to the state of request processing

Apache 2.1 移行に含まれる mod_filter では、 実行時に動的にフィルタチェインを有効にできます。 ですからたとえば、HTML を HTML フィルタで、JPEG 画像をそれとは 全く別のフィルタで、書き換えるようなプロクシを設定することもできます。 その上、そのプロクシはどのオリジンサーバがコンテンツを送信するか 事前情報無しでいいように構成できます。 これは、実行時に実際のコンテンツに応じて別々のフィルタプロバイダに ディスパッチするフィルタハーネスを使うことで実現されています。 チェインの中に直接入れて無条件に適用したり、動的にプロバイダとして 適用するようにしたりすることは、どんなフィルタでもできます。 たとえば、

top

フィルタの使い方

フィルタの使い方には二つの方法があります: シンプルとダイナミック。 一般的にはどちらかのみを使ったほうがよいでしょう。 これらを組み合わせて使用すると、予期しない結果になるかもしれません。 (とはいえ、シンプルな入力フィルタとシンプルあるいはダイナミックな 出力フィルタを組み合わせることは自由に出来ます。)

シンプルな方法は、入力フィルタのみを設定し、必要に応じて 静的なフィルタチェインを出力フィルタとして設定する方法です。 関連するディレクティブは、 SetInputFilter, SetOutputFilter, AddInputFilter, AddOutputFilter, RemoveInputFilter, RemoveOutputFilter になります。

ダイナミックな方法は、静的なものとフレキシブルなものを両方有効にする 方法で、mod_filter のページで述べられています。 関連するディレクティブは、 FilterChain, FilterDeclare, FilterProvider になります。

ディレクティブ AddOutputFilterByType はまだサポートされていますが、種々の問題をはらんでおり、非推奨です。 ダイナミックな設定方法を代わりに使ってください。

glossary.html100644 0 0 70616 11237400230 10760 0ustar 0 0 用語 - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2

用語

この用語集では Apacheに特化した用語と、 ウェブサーバ全般で一般的な用語をいくつか定義しています。 それぞれの概念の、より詳細な情報はリンク先にあります。

top

定義

アクセス制御
ネットワーク認可領域へのアクセスを制限します。Apache においては、 普通はアクセスの制限は URL に対するものとなります。
参照: 認証、承認、アクセス制御
アルゴリズム
有限回のステップで問題を解くためのあいまいでない式もしくは規則の 集合。暗号のためのアルゴリズムは通常 Cipher と呼ばれます。
APache eXtension Tool (apxs)
モジュール ソースを 動的共有オブジェクト (DSO) にコンパイルし、 Apache Web サーバにインストールする手助けをする perl スクリプト。
参照: マニュアルページ: apxs
Apache Portable Runtime (APR)
サーバ(訳注: Apache HTTP Server)と OS の 間の基本的なインターフェースの多くを提供する(訳注: OS の差を吸収する)ライブラリのセット。 APR は 独立した プロジェクトとして Apache HTTP Server と平行して開発が行われています。
参照: Apache Portable Runtime プロジェクト
認証
サーバ、クライアント、ユーザといったネットワークエンティティの 身元の特定。
参照: 認証、承認、アクセス制御
証明書
サーバやクライアントといったネットワークエンティティを認証するのに 使用されるデータレコード。証明書には (subject と呼ばれる) 所有者と、 (issuer と呼ばれる) 認証局 の署名、所有者の 公開鍵 と、CA による署名という X.509 の情報が含まれます。ネットワークエンティティはそれらの署名を CA 証明書を使って検証します。
参照: SSL/TLS 暗号化
証明書署名リクエスト (訳注: Certificate Signing Request) (CSR)
認証局 に提出 する未署名の 証明書。 認証局は CA 証明書秘密鍵 で署名します。 一旦 CSR に署名がなされると、それは本物の証明書になります。
参照: SSL/TLS 暗号化
証明局 (訳注: Certification Authority) (CA)
安全な方法で認証を行なったネットワークエンティティの証明書を 署名するための信頼できる第三者機関。他のネットワークエンティティは 証明書の保持者が CA に認証されたかを署名を検証することで調べることが できます。
参照: SSL/TLS 暗号化
Cipher
データ暗号化のためのアルゴリズム。例えば DES, IDEA, RC4 など。
参照: SSL/TLS 暗号化
暗号文
平文Cipher をかけられた結果。
参照: SSL/TLS 暗号化
Common Gateway Interface (CGI)
外部プログラムがリクエストを扱うことができるようにするための ウェブサーバと外部プログラム間のインタフェースの標準仕様。 インタフェースは元々 NCSA により定義 されていましたが RFC プロジェクト も存在します。
参照: CGI による動的コンテンツ
設定ディレクティブ
参照: ディレクティブ
設定ファイル
Apache の設定を制御する ディレクティブ の書かれたテキストファイル。
参照: 設定ファイル
CONNECT
データチャネルをそのまま HTTP 上でプロキシするための HTTP メソッド。SSL のような他の プロトコルをくるむために使うことができます。
コンテキスト
設定ファイル 中で、 特定の種類の ディレクティブ が許可されている場所。
参照: Apache のディレクティブの 説明に使われている用語
デジタル署名
証明書や他のファイルを検証するための暗号化されたテキストブロック。 認証局証明書 に埋め込まれた 公開鍵 のハッシュを作成し、 それを自身の 秘密鍵 で暗号化することで署名を作成します。 CA の公開鍵でのみその署名を復号することができますので、それにより 証明書 を保有するネットワークエンティティを CA が認証した ことを検証できます。
参照: SSL/TLS 暗号化
ディレクティブ
Apache のいろいろな振る舞いを制御する設定コマンド。ディレクティブは 設定ファイル に 書かれます。
参照: ディレクティブ索引
動的 共有オブジェクト (訳注: Dynamic Shared Object) (DSO)
必要に応じて読み込むことが可能な、Apache httpd とは 別にコンパイルされた モジュール
参照: 動的共有オブジェクトサポート
環境変数 (env-variable)
情報を保管したり、プログラム間の通信をするために使われる、 オペレーティングシステムのシェルにより管理されている名前付きの変数。 Apache も環境変数と呼ばれる内部変数を持っていますが、こちらは シェル環境ではなく、Apache の内部構造体に保持されています。
参照: Apache の環境変数
輸出強度削減 (訳注: Export-Crippled)
アメリカの Export Administration Regulations (EAR) (訳注: 輸出管理規則) に従うために暗号の強度 (とセキュリティ) を削減すること。輸出強度削減された暗号ソフトウェアは小さいキーに 制限され、通常総当たり攻撃で復号できてしまう 暗号文 を生成する ことになります。
参照: SSL/TLS 暗号化
フィルタ
サーバから送られるデータとサーバが受け取るデータに適用される処理。 入力フィルタはクライアントからサーバに送られたデータを処理し、 出力フィルタはサーバにある文書をクライアントに送る前に処理します。 例えば、INCLUDES 出力フィルタは Server Side Includes の文書を 処理します。
参照: フィルタ
完全修飾ドメイン名 (訳注: Fully-Qualified Domain-Name) (FQDN)
IP アドレスに解決できるホスト名と、ドメイン名からなるネットワーク エンティティの一意な名前。例えば、www はホスト名で、 example.com はドメイン名なので、 www.example.com は完全修飾ドメイン名になります。
ハンドラ
ファイルが呼ばれたときに行なわれる動作の Apache の内部での表現。 一般にファイルにはファイルの種類に応じて暗黙のハンドラが設定されて います。普通はすべてのファイルがサーバにより送られますが、別に 扱われる (訳注: handle) ファイルの種類も存在します。 例えば cgi-script はファイルが CGI として処理されるように指定します。
参照: Apache のハンドラの使用
ハッシュ
任意の文字列から固定長の文字列を生成する、数学的な一方向で不可逆な アルゴリズム。異なった入力文字列からは普通は違うハッシュが生成されます (ハッシュ関数に依存します)。
ヘッダ
実際のコンテンツの前に送られ、コンテンツを説明するメタ情報の 入った HTTP リクエストと応答の一部分。
.htaccess
ウェブツリーに置かれて、そのディレクトリとサブディレクトリに ディレクティブ を適用する 設定ファイル。 名前とは裏腹に、このファイルにはアクセス制御ディレクティブだけでなく、 ほとんどどんな種類のディレクティブでも書くことができます。
参照: 設定ファイル
httpd.conf
メインの Apache 設定 ファイル。デフォルトの場所は /usr/local/apache2/conf/httpd.conf ですが、実行時やコンパイル時の設定により違う場所に移動されて いるかもしれません。
参照: 設定ファイル
HyperText Transfer Protocol (HTTP)
World Wide Web で使われる標準の転送プロトコル。Apache は HTTP/1.1 と呼ばれ、RFC 2616 で定義されているプロトコルのバージョン 1.1 を実装しています。
HTTPS
The HyperText Transfer Protocol (Secure), World Wide Web での暗号化された標準の通信機構。これは実際は 単に SSL 上での HTTP です。
参照: SSL/TLS 暗号化
メソッド
HTTP の文脈では、 クライアントから指定されたリクエスト行に対応するリソース に対して行なう動作。HTTP では GET, POST, PUT といったようなメソッドがあります。
メッセージダイジェスト
メッセージのハッシュで、メッセージの内容が転送時に変更されていないことの検証に 使える。
参照: SSL/TLS 暗号化
MIME タイプ
送信されているドキュメントの種類を表すための方法。 この名前はフォーマットが Multipurpose Internet Mail Extensions から 借りてこられたことによります。これはスラッシュで分離された、 主タイプと副タイプからなります。例えば、text/html, image/gif, application/octet-stream など があります。HTTP では、MIME タイプは Content-Type ヘッダ で送信されます。
参照: mod_mime
モジュール
プログラムの独立した一部分。Apache の機能の多くは使用するかしないかを 選択できるモジュールの中にあります。Apache httpd に組み込まれているモジュールは静的モジュールと呼ばれ、 別に保存され、実行時に読み込むことのできるモジュールは 動的モジュール もしくは DSO と 呼ばれます。デフォルトで含まれているモジュールはbase モジュール と呼ばれます。Apache HTTP サーバの tarball の一部としては配られていない Apache 用のモジュールがあります。 それらは サードパーティモジュール と呼ばれます。
参照: モジュール索引
Module Magic Number (MMN)
Apache ソースコードで定義されている、モジュールのバイナリ互換性に 関する定数。バイナリ互換性が保てなくなるような Apache 内部の構造体や、 関数呼び出し、その他の API の重要な部分の変更があったときに変更されます。 MMN が変わると、すべてのサードパーティモジュールは少なくとも再コンパイルを する必要があり、場合によっては新しいバージョンの Apache で動作するために 少し変更する必要さえあるかもしれません。
OpenSSL
SSL/TLS 用のオープンソースツールキット
参照 http://www.openssl.org/#
パスフレーズ
秘密鍵のファイルを保護するための語句。権限の無いユーザが 暗号化するのを防ぎます。通常は単に Cipher の秘密の暗号用と復号用のキーです。
参照: SSL/TLS 暗号化
平文
暗号化されていないテキスト。
秘密鍵
受け取るメッセージの復号と送出するメッセージの署名に使われる、 公開鍵暗号 の 秘密鍵。
参照: SSL/TLS 暗号化
プロキシ
クライアントと オリジンのサーバ の間に存在する中間サーバ。 クライアントからのリクエストを受け取り、オリジンのサーバに送信して、オリジンの サーバからの応答をクライアントに返します。複数のクライアントが同じ コンテンツを要求する場合は、毎回元のサーバにリクエストを送る代わり プロキシはキャッシュからコンテンツを送り、応答時間を短縮することが できます。
参照: mod_proxy
公開鍵
所有者に向けられたメッセージの暗号化と所有者による署名の復号に使われる、 公開鍵暗号システムに おける公けにされている鍵。
参照: SSL/TLS 暗号化
公開鍵暗号
ある鍵を暗号に使い、別の鍵を復号に使う非対称暗号システムについての研究や その応用を指す。対応する鍵はキーペアと呼ばれます。非対称暗号とも呼ばれます。
参照: SSL/TLS 暗号化
正規表現 (Regex)
テキストのパターンを表現する方式の一つ。例えば、 「A で始まるすべての単語」や「すべての 10 桁の電話番号」や、 「コンマが二つあり、大文字の Q がないすべての文」というのでさえ表現 できます。 正規表現は Apache においても便利なもので、ファイルやリソースの集まりに対して 何らかの属性を適用することがとても柔軟にできます。例えば、 すべての "images" ディレクトリの下の、すべての .gif と .jpg ファイル は /images/.*(jpg|gif)$ と書くことができます。 Apache では PCRE ライブラリが提供する Perl 互換正規表現 (訳注: Perl Compatible Regular Expressions) を使います。
リバースプロキシ
クライアントには オリジンのサーバ のように見える プロキシ サーバ。セキュリティの ためや、負荷分散のためにクライアントからオリジンのサーバを隠したいときに 便利です。
Secure Sockets Layer (SSL)
Netscape Communications Corporation により TCP/IP ネットワーク上で一般の通信の認証と暗号用に作られたプロトコル。 最もよく使われているものは HTTPS つまり SSL 上での HyperText Transfer Protocol (HTTP) です。
参照: SSL/TLS 暗号化
Server Side Includes (SSI)
HTML ファイル中に処理ディレクティブを埋め込む技術の一つ。
参照: Server Side Includes 入門
セッション
一般的な通信における文脈情報。
SSLeay
Eric A. Young 氏による SSL/TLS を実装した元々のライブラリ。
対称暗号
一つの秘密鍵を暗号化と復号の両方に使う Cipher の 研究や応用を指す。
Tarball
tar ユーティリティを使ってまとめられたファイルのパッケージ。 Apache 配布は圧縮された tar アーカイブか pkzip で保管されています。
Transport Layer Security (TLS)
TCP/IP ネットワーク上での一般通信の認証と暗号化用に Internet Engineering Task Force (IETF) により作成された SSL の 後継プロトコル。TLS バージョン 1 は SSL バージョン 3 とほぼ同じです。
参照: SSL/TLS 暗号化
Uniform Resource Locator (URL)
Internet のリソースの名前、もしくはアドレス。これは正式には Uniform Resource Identifier と呼ばれるもののよく使われる非公式な名前です。URL は普通は、 httphttps といったスキームとホスト名、 パスからなります。このページの URL はおそらく http://httpd.apache.org/docs/2.2/glossary.html と思われます。
Uniform Resource Identifier (URI)
抽象的なリソースや物理リソースを同定するためのコンパクトな文字列。 正式には RFC 2396 で 定義されています。WWW で使われている URI は通常 URL と呼ばれます。
バーチャルホスト
一つの Apache を使って複数のウェブサイトを扱うこと。 IP バーチャルホスト は IP アドレスを使ってウェブサイトを 区別します。また 名前ベースのバーチャルホスト は ホストの名前だけを使って区別するので、同じ IP アドレス上での多くのサイトを ホストできます。
参照: Apache バーチャルホストの文書
X.509
SSL/TLS 認証に使われている International Telecommunication Union (ITU-T) により推奨されている認証証明書の形式。
参照: SSL/TLS 暗号化
handler.html100644 0 0 22332 11237400230 10522 0ustar 0 0 Apache のハンドラの使用 - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2

Apache のハンドラの使用

Apache のハンドラの使用に関して記述しています。

top

ハンドラとは

「ハンドラ」とは、ファイルが呼ばれたときに実行される動作の Apache における内部表現です。 通常、ファイルはファイル型に基づいた暗黙のハンドラがあります。 普通はすべてのファイルは単にサーバに扱われますが、 ファイルタイプの中には別に「ハンドル」(訳注: 扱う) されるものもあります。

ファイル型に関係なく、ファイルの拡張子や置いている場所に基づいて 明示的にハンドラを指定することもできます。 これはより優雅な解決法という点と、ファイルにタイプハンドラの両方を関連付けることができるという点で優れています。 (複数の拡張子のあるファイルも参照してください)。

ハンドラはサーバに組み込んだり、モジュールとして含めたり、 Action ディレクティブとして追加したりすることができます。 以下は標準配布に組み込まれているハンドラです。

top

CGI スクリプトを用いて静的なコンテンツを変更する

以下のディレクティブによって、拡張子が html であるファイルは footer.pl CGI スクリプトを起動するようになります。

Action add-footer /cgi-bin/footer.pl
AddHandler add-footer .html

CGI スクリプトは希望の修正や追加を行なって、元々要求された文書 (環境変数 PATH_TRANSLATED で指されています) を送る責任があります。

HTTP ヘッダのあるファイル

以下のディレクティブは send-as-is ハンドラを使用するように指示します。このハンドラは自分自身の HTTP ヘッダを持っているファイルに使用されます。ここでは、拡張子に関わらず、 /web/htdocs/asis ディレクトリにある全てのファイルは send-as-is ハンドラによって扱われます。

<Directory /web/htdocs/asis>
SetHandler send-as-is
</Directory>

top

プログラマ向けのメモ

ハンドラの機能を実装するために、利用すると便利かもしれないものが Apache API に追加されました。詳しく言うと、request_rec 構造体に新しいレコードが追加されたということです。

char *handler

もしモジュールがハンドラに関わりたい場合、 やらなければならないことは、リクエストが invoke_handler ステージに達する以前に r->handler を設定することだけです。ハンドラはコンテントタイプの代わりに ハンドラ名を使うようになっていること以外は、以前と同じように実装されています。 必ず要求されているわけではありませんが、メディアタイプ の名前空間を侵さないように、ハンドラの名前にはスラッシュを含まない、 ダッシュ (訳注: "-") で分離された名前を付ける習慣になっています。

howto/access.html100644 0 0 22441 11237400230 11507 0ustar 0 0 Access Control - Apache HTTP Server
<-
Apache > HTTP Server > Documentation > Version 2.2 > How-To / Tutorials

Access Control

Access control refers to any means of controlling access to any resource. This is separate from authentication and authorization.

top

Related Modules and Directives

Access control can be done by several different modules. The most important of these is mod_authz_host. Other modules discussed in this document include mod_setenvif and mod_rewrite.

top

Access control by host

If you wish to restrict access to portions of your site based on the host address of your visitors, this is most easily done using mod_authz_host.

The Allow and Deny directives let you allow and deny access based on the host name, or host address, of the machine requesting a document. The Order directive goes hand-in-hand with these two, and tells Apache in which order to apply the filters.

The usage of these directives is:

Allow from address

where address is an IP address (or a partial IP address) or a fully qualified domain name (or a partial domain name); you may provide multiple addresses or domain names, if desired.

For example, if you have someone spamming your message board, and you want to keep them out, you could do the following:

Deny from 10.252.46.165

Visitors coming from that address will not be able to see the content covered by this directive. If, instead, you have a machine name, rather than an IP address, you can use that.

Deny from host.example.com

And, if you'd like to block access from an entire domain, you can specify just part of an address or domain name:

Deny from 192.168.205
Deny from phishers.example.com moreidiots.example
Deny from ke

Using Order will let you be sure that you are actually restricting things to the group that you want to let in, by combining a Deny and an Allow directive:

Order deny,allow
Deny from all
Allow from dev.example.com

Listing just the Allow directive would not do what you want, because it will let folks from that host in, in addition to letting everyone in. What you want is to let only those folks in.

top

Access control by environment variable

mod_authz_host, in conjunction with mod_setenvif, can be used to restrict access to your website based on the value of arbitrary environment variables. This is done with the Allow from env= and Deny from env= syntax.

SetEnvIf User-Agent BadBot GoAway=1
Order allow,deny
Allow from all
Deny from env=GoAway

Warning:

Access control by User-Agent is an unreliable technique, since the User-Agent header can be set to anything at all, at the whim of the end user.

In the above example, the environment variable GoAway is set to 1 if the User-Agent matches the string BadBot. Then we deny access for any request when this variable is set. This blocks that particular user agent from the site.

An environment variable test can be negated using the =! syntax:

Allow from env=!GoAway

top

Access control with mod_rewrite

The [F] RewriteRule flag causes a 403 Forbidden response to be sent. Using this, you can deny access to a resource based on arbitrary criteria.

For example, if you wish to block access to a resource between 8pm and 6am, you can do this using mod_rewrite.

RewriteEngine On
RewriteCond %{TIME_HOUR} >20 [OR]
RewriteCond %{TIME_HOUR} <07
RewriteRule ^/fridge - [F]

This will return a 403 Forbidden response for any request after 8pm or before 7am. This technique can be used for any criteria that you wish to check. You can also redirect, or otherwise rewrite these requests, if that approach is preferred.

top

More information

You should also read the documentation for mod_auth_basic and mod_authz_host which contain some more information about how this all works. mod_authn_alias can also help in simplifying certain authentication configurations.

See the Authentication and Authorization howto.

howto/auth.html100644 0 0 57532 11237400230 11220 0ustar 0 0 認証、承認、アクセス制御 - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2 > How-To / チュートリアル

認証、承認、アクセス制御

This translation may be out of date. Check the English version for recent changes.

「認証」とは、誰かが自分は誰であるかを主張した場合に、 それを確認するための全過程を指します。「承認」とは、 誰かが行きたい場所に行けるように、あるいは欲しい情報を 得ることができるようにするための全過程を指します。

top

関連するモジュールとディレクティブ

top

はじめに

もし機密の情報や、ごくごく少数グループの人向けの情報を ウェブサイトに置くのであれば、この文書に書かれている テクニックを使うことで、そのページを見ている人たちが 望みの人たちであることを確実にできるでしょう。

この文書では、多くの人が採用するであろう、 ウェブサイトの一部分を保護する「一般的な」 方法についてカバーしています。

top

準備

この文書で取り扱われるディレクティブは、 メインサーバ設定ファイル (普通は <Directory> セクション中) か、あるいはディレクトリ毎の設定ファイル (.htaccess ファイル) かで用います。

.htaccess ファイルを用いるのであれば、 これらのファイルに認証用のディレクティブを置けるように サーバの設定をしないといけないでしょう。これは AllowOverride ディレクティブで可能になります。 AllowOverride ディレクティブでは、ディレクトリ毎の設定ファイル中に置くことのできる ディレクティブを、もしあれば、指定します。

認証について話を進めているので、次のような AllowOverride ディレクティブが必要になるでしょう。

AllowOverride AuthConfig

そうでなく、メインサーバ設定ファイルの中に 直接置くのであれば、当然ながらそのファイルへの書き込み 権限を持っていなければならないでしょう。

また、どのファイルがどこに保存されているか知るために、 サーバのディレクトリ構造について少し知っておく 必要があるでしょう。 これはそんなに難しくないので、この文書中で ディレクトリ構造について知っておく必要がある場面では、 明らかになるようにします。

top

動作させる

では、サーバ上のあるディレクトリをパスワードで保護する 基本手順を示します。

パスワードファイルを作る必要があります。 このファイルは、ウェブからアクセスできる場所に 置くべきではありません。他の人がパスワードファイルを ダウンロードできないようにするためです。例えば、 /usr/local/apache/htdocs でドキュメントを 提供しているのであれば、パスワードファイルは /usr/local/apache/passwd などに置いた方が良いでしょう。

ファイルを作るためには、Apache 付属の htpasswd を使います。このコマンドは Apache をどこにインストールしようとも、 インストールディレクトリの bin ディレクトリ以下に置かれます。ファイルを作るには、次のように タイプしてください。

htpasswd -c /usr/local/apache/passwd/passwords rbowen

htpasswd は、パスワードを要求し、その後 確認のためにもう一度入力するように要求してきます。

# htpasswd -c /usr/local/apache/passwd/passwords rbowen
New password: mypassword
Re-type new password: mypassword
Adding password for user rbowen

もし htpasswd がパスの中に入っていない場合は、 もちろん、実行するためにプログラムまでのフルパスを タイプする必要があります。私のサーバであれば、 /usr/local/apache/bin/htpasswd にプログラムが置かれています。

次に、サーバがパスワードを要求するように設定して、 どのユーザがアクセスを許されているかをサーバに知らせなければ なりません。 httpd.conf を編集するか .htaccess ファイルを使用するかで 設定します。例えば、ディレクトリ /usr/local/apache/htdocs/secret を保護したい場合は、 /usr/local/apache/htdocs/secret/.htaccess か httpd.conf 中の <Directory /usr/local/apache/apache/htdocs/secret> セクションに 配置して、次のディレクティブを使うことができます。

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /usr/local/apache/passwd/passwords
Require user rbowen

個々のディレクティブについて見てみましょう。 AuthType ディレクティブはどういう認証方法でユーザの認証を行うかを 選択します。最も一般的な方法は Basic で、これは mod_auth_basic で実装されています。しかしながら、 これは気を付けるべき重要なポイントなのですが、 Basic 認証はクライアントからサーバへ、 パスワードを暗号化せずに送ります。ですから、 この方法は特に機密性の高いデータに対しては用いるべきでは ありません。 Apache ではもう一つ別の認証方法: AuthType Digest をサポートしています。 この方法は mod_auth_digest で実装されていて、もっと安全です。 ごくごく最近のクライアントしか Digest 認証をサポートしていないようです。

AuthName ディレクティブでは、認証に使う Realm (訳注: 領域) を設定します。Realm は大きく分けて二つの機能を提供します。 一つ目は、クライアントがパスワードダイアログボックスの 一部としてユーザにこの情報をよく提示する、というものです。 二つ目には、クライアントが与えられた認証領域に対してどのパスワードを 送信すれば良いのかを決定するために使われる、という機能です。

例えば、"Restricted Files" 領域中で 一度認証されれば、同一サーバ上で "Restricted Files" Realm としてマークされたどんな領域でも、クライアントは 自動的に同じパスワードを使おうと試みます。 このおかげで、複数の制限領域に同じ realm を共有させて、 ユーザがパスワードを何度も要求される事態を 防ぐことができます。もちろん、セキュリティ上の理由から、 サーバのホスト名が変わればいつでも必ず、 クライアントは再びパスワードを尋ねる必要があります。

AuthUserFile ディレクティブは htpasswd で作った パスワードファイルへのパスを設定します。 ユーザ数が多い場合は、リクエスト毎のユーザの認証のための プレーンテキストの探索が非常に遅くなることがあります。 Apache ではユーザ情報を高速なデータベースファイルに 保管することもできます。 mod_authn_dbm モジュールが AuthDBMUserFile ディレクティブを提供します。これらのファイルは dbmmanage プログラムで作成したり操作したりできます。 Apache モジュールデータベース中にあるサードパーティー製の モジュールで、その他多くのタイプの認証オプションが 利用可能です。

最後に、Require ディレクティブが、サーバのこの領域にアクセスできるユーザを 指定することによって、プロセスの承認部分を提供します。 次のセクションでは、Require ディレクティブの様々な用法について述べます。

top

複数の人が入れるようにする

上記のディレクティブは、ただ一人 (具体的にはユーザ名 rbowen の誰か) がディレクトリに 入れるようにします。多くの場合は、複数の人が 入れるようにしたいでしょう。ここで AuthGroupFile の登場です。

もし複数の人が入れるようにしたいのであれば、 グループに属するユーザの一覧の入っている、グループ名のついた グループファイルを作る必要があります。このファイルの 書式はきわめて単純で、お好みのエディタで生成できます。 ファイルの中身は次のようなものです。

GroupName: rbowen dpitts sungo rshersey

一行にスペース区切りで、グループに所属するメンバーの 一覧をならべるだけです。

既に存在するパスワードファイルにユーザを加える場合は、 次のようにタイプしてください。

htpasswd /usr/local/apache/passwd/passwords dpitts

以前と同じ応答が返されますが、新しいファイルを 作るのではなく、既にあるファイルに追加されています。 (新しいパスワードファイルを作るには -c を使います。)

ここで次のようにして .htaccess ファイルを 修正する必要があります。

AuthType Basic
AuthName "By Invitation Only"
AuthUserFile /usr/local/apache/passwd/passwords
AuthGroupFile /usr/local/apache/passwd/groups
Require group GroupName

これで、グループ GroupName にリストされていて、 password ファイルにエントリがある人は、 正しいパスワードをタイプすれば入ることができるでしょう。

もっと特定せずに複数のユーザが入れるようにする、 もう一つの方法があります。グループファイルを作るのではなく、 次のディレクティブを使えばできます。

Require valid-user

require user rbowen 行でなく、上記を使うと、 パスワードファイルにリストされている人であれば誰でも 許可されます。 単にパスワードファイルをグループ毎に分けておくことで、 グループのような振る舞いをさせることもできます。 このアプローチの利点は、Apache は二つではなく、 ただ一つのファイルだけを検査すればよいという点です。 欠点は、たくさんのパスワードファイルを管理して、その中から AuthUserFile ディレクティブに正しいファイルを参照させなければならない点です。

top

起こりえる問題

Basic 認証が指定されている場合は、 サーバにドキュメントをリクエストする度に ユーザ名とパスワードを検査しなければなりません。 これは同じページ、ページにある全ての画像を リロードする場合であっても該当します (もし画像も保護されたディレクトリから来るのであれば) 。 予想される通り、これは動作を多少遅くします。 遅くなる程度はパスワードファイルの大きさと比例しますが、 これは、ファイルを開いてあなたの名前を発見するまで ユーザ名のリストを読まなければならないからです。 そして、ページがロードされる度にこれを行わなければ なりません。

結論としては、一つのパスワードファイルに置くことのできる ユーザ数には実質的な限界があります。 この限界はサーバマシンの性能に依存して変わりますが、 数百のエントリを越えたあたりから速度低下が見られると予期されています。 その時は他の認証方法を考慮に入れた方が良いでしょう。

top

もっと巧みに制御できない ?

ユーザ名とパスワードによる認証は認証の一つの方法に過ぎません。 しばしば誰であるかということとは違う何かに基づいて、 入れるようにしたくなることもあるでしょう。 例えばその人がどこから来ているかといったことです。

AllowDeny ディレクティブを使って、ドキュメントを要求してきたマシンの ホスト名やホストアドレスに基づいて許可不許可を制御できます。 Order ディレクティブはこの二つと連携して動作し、Apache にどの順番でフィルタを適用するかを知らせます。

これらのディレクティブの使い方は次のようになります。

Allow from address

ここで、address は IP アドレス (または IP アドレスの一部)、あるいは完全修飾ドメイン名 (またはドメイン名の一部) です。 必要であれば複数のアドレスやドメイン名を指定できます。

例えば、もし誰かが掲示板を攻撃していて、 その人を閉め出したいのであれば、 次のようにすることができます。

Deny from 205.252.46.165

このアドレスから来る人は、このディレクティブの範囲内の コンテンツを見ることができません。もし IP アドレスの代わりにマシン名があれば、それを使えます。

Deny from host.example.com

ドメイン全体からのアクセスを防ぎたければ、 単にアドレスやドメイン名の一部を指定することができます。

Deny from 192.101.205
Deny from cyberthugs.com moreidiots.com
Deny from ke

Order を使うことで、 DenyAllow の組み合わせで 入っても良いグループが本当に確実に限定できているようにできます。

Order deny,allow
Deny from all
Allow from dev.example.com

Allow ディレクティブを単純に列挙するのでは望みの動作をしないでしょう。 なぜなら、全ての人が入れるということに加えて、 指定したホストからの人が入れるようにするからです。 やりたいことは、指定した人たちだけが入れるように することです。

top

追加情報

これら全てがどのように動作するかについて もっと多くの情報が書かれている mod_auth_basicmod_authz_host の文書も読むとよいでしょう。

howto/cgi.html100644 0 0 77235 11237400230 11023 0ustar 0 0 Apache Tutorial: CGI による動的コンテンツ - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2 > How-To / チュートリアル

Apache Tutorial: CGI による動的コンテンツ

top

はじめに

CGI (Common Gateway Interface) は、ウェブサーバが コンテンツ生成をする外部プログラムと協調して動作するための方法を 定義しています。そのプログラムはしばしば CGI プログラムや CGI スクリプトと呼ばれます。CGI は、ウェブサイトに動的な コンテンツを置くための最も簡単で一般的な方法です。このドキュメントは、 Apache ウェブサーバで CGI を設定し、 CGI プログラムを書き始めるための入門書となるでしょう。

top

CGI を許可するように Apache を設定する

CGI プログラムを正しく動作させるには、CGI を許可するように Apache の設定を行う必要があります。 これを行なうための方法がいくつかあります。

ScriptAlias

ScriptAlias ディレクティブを使用して、 CGI プログラム用の特別な別ディレクトリを Apache に設定します。 Apache は、このディレクトリ中の全てのファイルを CGI プログラムであると仮定します。 そして、この特別なリソースがクライアントから要求されると、 そのプログラムの実行を試みます。

ScriptAlias ディレクティブは以下のように使用します:

ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/

デフォルト位置に Apache をインストールしたならば、 この例はデフォルト状態の httpd.conf 設定ファイルに含まれています。 ScriptAlias ディレクティブは、URL の前に付加するディレクトリを定義する Alias ディレクティブとかなり似ています。 AliasScriptAlias は通常、DocumentRoot ディレクトリ外のディレクトリのために使用されます。 AliasScriptAlias との差は、ScriptAlias が接頭辞で始まるすべての URL は CGI プログラムとみなされるという追加の意味を含んでいることです。 従って、上記の例では、/cgi-bin/ で始まるリソースへのあらゆるリクエストに対して、ディレクトリ /usr/local/apache2/cgi-bin/ から提供し、それらを CGI プログラムとして扱うよう Apache に示します。

例えば、URL http://www.example.com/cgi-bin/test.pl が要求された場合、Apache は ファイル /usr/local/apache2/cgi-bin/test.pl を実行し、その出力を返すことを試みます。 もちろん、ファイルが存在し、実行可能であり、決められた方法で出力を返します。 そうでなければ、Apache はエラーメッセージを返します。

ScriptAlias ディレクトリ外の CGI

CGI プログラムは、セキュリティ上の理由から ScriptAlias されたディレクトリに制限されることがしばしばあります。この方法により、 CGI プログラムを使用できるユーザを管理者が厳しく制御することができます。 しかしながら、適切なセキュリティ事前対策がとられるならば、CGI プログラムを任意のディレクトリで実行できないようにする理由はありません。 例えば、ユーザに UserDir ディレクティブで彼らのホームディレクトリ配下にウェブコンテンツを持たせたいとします。 もし、彼らが CGI プログラムを持つことを望んでいても、メインの cgi-bin ディレクトリへのアクセスができない場合、 CGI プログラムを実行することができる他の場所が必要になります。

任意のディレクトリで CGI の実行を許可するには二段階の設定が必要です。 まず、AddHandlerSetHandler ディレクティブによって cgi-script ハンドラが可能になっている必要があります。 次に、Options ディレクティブで ExecCGI が指定されていなければなりません。

CGI の実行を可能にするために Options を明示的に使用する

サーバのメインの設定ファイル中で Options ディレクティブを明示的に使用することで、特定のディレクトリ配下で CGI の実行を許可するように指定することができます:

<Directory /usr/local/apache2/htdocs/somedir>
Options +ExecCGI
</Directory>

上記ディレクティブは、CGI ファイルの実行を可能にするよう Apache に伝えます。また、どのファイルが CGI ファイルかを サーバに伝える必要があります。次の AddHandler ディレクティブの例では、cgi または pl を拡張子に持つすべてのファイルを CGI プログラムとしてみなすことをサーバに伝えます:

AddHandler cgi-script .cgi .pl

.htaccess ファイル

.htaccess チュートリアルhttpd.conf を変更できない場合にどうやって CGI プログラムを 使えるようにするかを説明しています。

User ディレクトリ

.cgi で終わるすべてのファイルに対して CGI プログラムの 実行を許可するには、以下の設定を使用できます。

<Directory /home/*/public_html>
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>

ユーザディレクトリの cgi-bin サブディレクトリの すべてのファイルを CGI プログラムとして指定したい場合には 以下のようなものを使います。

<Directory /home/*/public_html/cgi-bin>
Options ExecCGI
SetHandler cgi-script
</Directory>

top

CGI プログラムを書く

「通常の」プログラミングと CGI プログラミングの間には主に二つの違いがあります。

一つは、CGI プログラムのすべての出力には MIME-type ヘッダを付けなければなりません。 これはどのような種類のコンテンツを受け取っているかをクライアントに示す HTTP ヘッダです。ほとんどの場合では、次のように出力します:

Content-type: text/html

もう一つは、出力を HTML か、ブラウザが表示することができる何か他の形式にする必要があります。 大抵の場合は HTML でしょうが、GIF イメージや他の非 HTML コンテンツを出力する CGI プログラムを書くこともあるでしょう。

これら二点以外では、CGI プログラムを書くことは、 あなたが書いている他のプログラムとよく似ているでしょう。

最初の CGI プログラム

次に示すのは、ブラウザに 1 行印字する CGI プログラムの例です。以下を入力し、first.pl というファイルに保存し、それを cgi-bin ディレクトリに置いてください。

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, World.";

Perl に精通していなくても、 何が起こるかを理解することはできるでしょう。1 行目は、 /usr/bin/perl で見つけられるインタプリタに このファイルを供給することでこのプログラムが実行されることを Apache に (シェル上で実行しようとしているならば、そのシェルに ) 示します。2 行目は、前述したとおり content-type の定義を印字します。 これには復帰改行の二つの組を後に付加します。 これにより、ヘッダの終りに空行が置かれ、HTTP ヘッダの終りとボディの始まりを示します。3 行目は、"Hello, World." という文字列を印字し、これで終りとなります。

好みのブラウザを開き、アドレス

http://www.example.com/cgi-bin/first.pl

あるいはファイルを置いたロケーションを指定すると、 Hello, World. という 1 行がブラウザウィンドに現れるでしょう。 それはあまりエキサイティングなことではありません。 しかし、これがうまく動けば、 他のどのようなものでも動かすことができるようになります。

top

しかし、まだ動かない !

ウェブから CGI プログラムへのアクセスを行なったとき、 ブラウザで見る可能性がある四つの基本的なことがあります:

CGI プログラムの出力
素晴らしい ! それはすべてがうまく動いたことを意味します。 出力が正常だけれども、ブラウザが正常に処理してくれない場合は、 正しい Content-Type を CGI プログラム内で セットしたかを確認してください。
CGI プログラムのソースコード、または "POST Method Not Allowed" というメッセージ
これは、CGI プログラムを処理できるよう Apache を適切に設定していなかったことを意味します。「CGI を許可するように Apache を設定する」の章を読み直し、 あなたが何を間違えたかを探してみてください。
メッセージが "Forbidden" で始まっている
これはパーミッションの問題ということを意味します。 Apache のエラーログと、後述の「ファイルのパーミッション」 の章をチェックしてください。
"Internal Server Error" というメッセージ
Apache のエラーログをチェックすると、"Premature end of script headers" というログが記録されていると思います。そして、おそらく CGI プログラムによって生成されたエラーメッセージも記録されているでしょう。 この場合、CGI プログラムが適切な HTTP ヘッダを出力できない原因を知るために、 以下の各章でチェックしてみてください。

ファイルのパーミッション

サーバはあなたの権限で実行されていないのを忘れないように。 つまり、起動するとき、サーバは特権をもたないユーザ - 通常 nobodywww の権限で実行されます。したがって、あなたが所有する ファイルを実行するには別のパーミッションが必要となります。 通常、nobody が実行するのに十分なパーミッションを与える方法は、 ファイルに誰でも実行可能とするパーミッションを与えることです:

chmod a+x first.pl

また、もしあなたのプログラムが他のファイルを読み書きするならば、 それらのファイルは、これが可能となる正しいパーミッション を持っている必要があります。

パス情報と環境

コマンドラインからプログラムを実行するとき、 意識しなくてもシェルに渡される情報があります。 例えば、参照するファイルのためにどこを検索したらよいかを シェルに伝える PATH があります。

プログラムが CGI プログラムとしてウェブサーバによって実行されるとき、 それは同じ PATH ではないかもしれません。 CGI プログラム内で呼び出すあらゆるプログラム (例えば、sendmail のようなもの) は、 フルパスで指定する必要があるでしょう。それにより、CGI プログラムを実行しようとしたとき、 シェルはそのようなプログラムを見つけることができます。

同様なことは、スクリプトのインタプリタ (しばしば perl) へのパスで、CGI プログラムの 1 行目に次のように示されます:

#!/usr/bin/perl

これがインタープリタへの実際のパスであることを確認しておきます。

また、CGI プログラムが他の環境変数に依存している場合は、その環境変数が Apache から渡されるようにする必要があります。

プログラムエラー

CGI プログラムが失敗するのは大抵、プログラム自身に問題がある場合です。 一度 CGI の使い方を理解し、前述の二つの誤りを犯していないならば、 まず間違いなくそうでしょう。ブラウザを使ってテストする前に まず確認することは、コマンドラインからプログラムが実行できることです。 例えば、以下を実行してみてください:

cd /usr/local/apache2/cgi-bin
./first.pl

(perl インタプリタは呼ばないでください。 シェルと Apache がスクリプトの最初の行の パス情報 を使って見つけます。)

最初にプログラムから出力されるのは Content-Type を含み、 後に空行の続く HTTP ヘッダでなければなりません。他のものが出力されている 場合は、Apache はこのプログラムをサーバ経由で実行しようとしたときには Premature end of script headers エラーを出力します。詳細は 上記の CGI プログラムを書く を読んでください。

エラーログ

エラーログは友達です。 全てのうまくいかないことは、エラーログにメッセージを生成します。 必ずそれを最初に見るべきです。 もし、あなたがウェブサイトを主催している場所が エラーログの参照を許していないならば、きっと他のサイトで主催するべきです。 エラーログの読み方を学ぶことで、ほとんど全ての問題が迅速に確認され、 迅速に解決されるということが分かるでしょう。

Suexec

suexec サポートプログラムは バーチャルホストやユーザのホームディレクトリの場所に依って CGI プログラムを違うユーザ権限の下で走らせることを可能にします。 Suexec の権限のチェックは非常に厳しく、それを満たさない場合は CGI プログラムが Premature end of script headers エラーで 実行されません。

suexec を使っているかどうかを調べためには apachectl -V を実行して、SUEXEC_BIN の場所を調べてください。 Apache がそこに suexec のバイナリを発見した場合は、suexec が 使用されます。

suexec を完全に理解していない限り、使うべきではありません。 suexec を無効にするには、SUEXEC_BIN から指されている suexec バイナリを削除 (か名前を変更) するだけです。 suexec を読んだ後で、まだそれを 使いたいのであれば、suexec -V を実行して suexec の ログファイルの位置を調べ、そのログファイルを使ってポリシー違反を 見つけてください。

top

裏で何が起こっているのか?

CGI プログラミングに習熟すると、 裏で起こっていることについて更に理解することの役に立ちます。 ブラウザとサーバがどのように相互通信するかについては特にそうです。 なぜなら、"Hello, World." を印字するプログラムを書くことはおおいに結構ですが、 それは特に有益ではありません。

環境変数

環境変数は、 あなたがコンピュータを使うときに辺りに存在している値です。 それらは、パス (コマンドをタイプしたときに実行する実際のファイルを探し出すところ)、 ユーザ名、端末型などのような便利なものです。 通常、普段使用している環境変数の完全なリストを調べるには、 コマンドプロンプトで env を入力します。

CGI の処理中、サーバとブラウザも環境変数を設定し、 それにより相互に通信することができるようになります。 その環境変数は、ブラウザタイプ (Netscape, IE, Lynx)、サーバタイプ (Apache, IIS, WebSite)、実行されている CGI プログラムの名前などです。

これらの変数は CGI プログラマが使用できます。 そして、それはクライアントとサーバの通信の話の半分です。 必要な変数の完全なリストは http://hoohoo.ncsa.uiuc.edu/cgi/env.html にあります。

以下の単純な Perl CGI プログラムは、渡される全ての環境変数を表示します。同様のプログラムは、 Apache ディストリビューションの cgi-bin ディレクトリに二つ含まれています。 いくつかの変数が必須であり、いくつかは任意であることに注意してください。 そして、公式のリストにはないいくつかの変数が表示されているかもしれません。 さらに、Apache はデフォルトで用意されている基本的なものに あなた自身の環境変数を加えるための、 多くの異なる方法を用意してします。

#!/usr/bin/perl
print "Content-type: text/html\n\n";
foreach $key (keys %ENV) {
print "$key --> $ENV{$key}<br>";
}

STDIN と STDOUT

サーバとクライアント間のもう一つの通信は、標準入力 (STDIN)と標準出力 (STDOUT) を通じて行なわれます。通常の文脈において、STDIN はキーボードやプログラムが動作するために与えられるファイルを意味し、 STDOUT は通常コンソールまたはスクリーンを意味します。

ウェブフォームから CGI プログラムへPOST したとき、フォームのデータは特別なフォーマットで束ねられ、 STDIN を通して、CGI プログラムに引き渡されます。 プログラムはデータがキーボード もしくはファイルから来ていたかのように処理することができます。

「特別なフォーマット」はとても単純です。フィールド名と値はイコール (=) で結ばれます。そして値の組はアンパサンド (&) で結ばれます。 スペース、アンパサンド、イコールのような面倒な文字は、 それらが動作を駄目にしないようにその文字に相当する 16 進に変換されます。 全データ文字列は、以下のようになります:

name=Rich%20Bowen&city=Lexington&state=KY&sidekick=Squirrel%20Monkey

時々、このような文字列が URL に付加されるのを見るでしょう。その場合、サーバは QUERY_STRING という環境変数にその文字列を入れます。それは GET リクエストと呼ばれます。 HTML フォームでは、データを渡すために GETPOST のどちらを使用するかを、FORM タグの METHOD 属性の設定で指定します。

CGI プログラムは、その文字列を役に立つ情報に分割する責任があります。 幸いにも、そのデータ処理を助けるライブラリやモジュールが存在します。 これらは、CGI プログラムの他の面でも同様に役に立ちます。

top

CGI モジュール/ライブラリ

CGI プログラムを書くとき、面倒な仕事の大部分をしてくれる コードライブラリまたはモジュールを使うことを検討すべきです。 これはエラーを減らし、早い開発につながります。

Perl で CGI プログラムを書いているなら、モジュールは CPAN で提供されています。 この目的のための最も普及しているモジュールは CGI.pm です。 CGI::Lite も検討しましょう。これは、ほとんどのプログラム において必要とするすべての機能の最小セットの実装です。

C で CGI プログラムを書いているなら、いろいろな オプションがあります。これらの内の一つは http://www.boutell.com/cgic/ で提供されている CGIC ライブラリです。

top

更なる情報

CGI に関する情報はウェブで数多く提供されています。CGI の問題については Usenet の comp.infosystems.www.authoring.cgi で、 他のユーザと論議することができます。HTML Writers Guide の -servers メーリングリストは、あなたの質問に回答してくれる偉大なリソースです。 http://www.hwg.org/lists/hwg-servers/ で更に多くを探し出すことができます。

そしてもちろん、おそらく CGI プログラムの動作に関する詳細の全てが記述されている CGI の仕様を読むべきです。オリジナルバージョンを NCSA で、アップデートされたドラフトを Common Gateway Interface RFC プロジェクトで参照することができます。

CGI の問題について、加わっているメーリングリストまたはニュース グループに質問を送るとき、起こったもの、起こってほしいこと、 実際に起こったことがどう違うか、使用しているサーバ、 CGI プログラムを記述している言語に関する十分な情報と、 可能であれば問題のコードを提供するようにしてください。 そうすることで、問題がより間単に見つかるようになります。

Apache のソースコードにおいて問題を発見したことを確信していない限り、 CGI の問題に関する質問を Apache バグデータベースに送るべきでない ことに注目してください。

howto/htaccess.html100644 0 0 60300 11237400230 12037 0ustar 0 0 Apache チュートリアル: .htaccess ファイル - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2 > How-To / チュートリアル

Apache チュートリアル: .htaccess ファイル

.htaccess ファイルはディレクトリ毎に設定を変更する方法を 提供します。

top

.htaccess ファイル

top

.htaccess ファイルとは何か/その使い方

.htaccess ファイル (「分散設定ファイル」) は ディレクトリ毎に設定を変更する方法を提供します。ディレクティブの 書かれたファイルをディレクトリに置くことで、そのディレクトリとその サブディレクトリすべてにディレクティブを適用させることができます。

注:

.htaccess ファイルを別の名前にしたい場合は、 AccessFileName ディレクティブを 使って変更することができます。例えば、そのファイルを .config という名前にしたい場合は、以下の設定をサーバ設定ファイルに入れることが できます:

AccessFileName .config

一般に、.htaccess ファイルの構文は 主設定ファイル と同じです。これらのファイルに書くことのできるディレクティブは AllowOverride ディレクティブにより決まります。 このディレクティブは、.htaccess ファイルに 書かれたディレクティブの中で、、 どのディレクティブが適用されるかをカテゴリー単位で指定します。 .htaccess に書くことのできるディレクティブであれば、 説明文書には「上書き」という項目があり、.htaccess に書くことができるように なるための AllowOverride の値が指定されています。

例えば、AddDefaultCharset ディレクティブの説明を 見ると、.htaccess ファイルでの使用が許可されていることが わかります。 (ディレクティブの概要の所にある「コンテキスト」と書かれている 行を見てください。) 上書きと書かれている行には FileInfo とあります。ですから、.htaccess 中の このディレクティブが有効になるためには、少なくとも AllowOverride FileInfo が設定されている必要があります。

例:

コンテキスト: サーバ設定ファイル,バーチャルホスト,ディレクトリ,.htaccess
上書き: FileInfo

あるディレクティブを .htaccess ファイルに書くことができるか どうかわからないときは、そのディレクティブの説明を探して、".htaccess" のための「コンテキスト」の行を調べてください。

top

いつ .htaccess ファイルを使う(使わない)か。

一般的に、サーバの主設定ファイルにアクセスできない場合を除いて、 .htaccess ファイルの使用は極力避けてください。 世の中には、例えば、ユーザ認証は常に .htaccess ファイルで 行なわなければならない、という誤解が広まっていますが、まったくそんなことは ありません。ユーザ認証の設定はサーバ主設定ファイルに書くことができ、 実際、その方がより良い設定方法です。

.htaccess ファイルはコンテンツ提供者がディレクトリ毎の 設定を行ないたいけれど、サーバシステムの root アクセス権限を持っていない という場合にのみ使うべきものです。サーバ管理者が頻繁に設定変更を行ないたくは ない、というときには個々のユーザが .htaccess ファイルを使って 自分で設定の変更を行なうことを許可した方が良いときもあるでしょう。 これは特に、ISP が複数のユーザのサイトを一つのマシンでホストしていて、 各ユーザが設定の変更をできるようにしたいようなときにあてはまります。

しかし、普通は可能であれば .htaccess ファイルの使用は 避けてください。.htaccess ファイルに書こうと考えるような すべての設定は、サーバの主設定ファイルの <Directory> セクションで同じように行なうことが できます。

.htaccess ファイルの使用を避ける理由は主に二つあります。

一つ目はサーバの性能の問題です。AllowOverride ディレクティブが .htaccess ファイルの設定を許可している場合は、Apache は 各ディレクトリで .htaccess ファイルを探します。 ですから、.htaccess ファイルを許可すると、実際に使用しているか どうかに関わらず、性能の低下を招くことになります! また、.htaccess ファイルは文書がリクエストされる度に読み込まれます。

さらに、Apache は適用すべきディレクティブを集めるために、すべての 上位のディレクトリの .htaccess ファイルを探す必要があることにも 注意してください。(ディレクティブが適用される方法を 参照してください。)ですから、/www/htdocs/example にある ファイルがリクエストされたときは、Apache は以下のファイルを調べます。

/.htaccess
/www/.htaccess
/www/htdocs/.htaccess
/www/htdocs/example/.htaccess

ですから、そのディレクトリのそれぞれのファイルへのアクセスに対して、 上の例のファイルがまったく存在しないときでも、追加のファイルシステムの アクセスが行なわれることになります。(これは、.htaccess/ に対して有効になっているときの場合で、普通はそうなって いないことに注意してください。)

二つ目はセキュリティです。ユーザにサーバの設定を変更することを 許可することになりますので、あなた自身が管理できない変更をされる 恐れがあります。ユーザにこの特権を与えるのが良いのかどうか、十分 検討してください。また、ユーザに与える権限が必要なものよりも少なすぎると、 余分な技術サポート報告を受け取るようになる可能性が高いことにも 注意してください。確実に、ユーザにどの程度の権限を与えたか明確に告げるように してください。AllowOverride に 何を設定したかということと、関連する文書を示すことで、 後々の混乱をぐっと減らすことが できます。

ところで、ディレクティブの書かれた .htaccess/www/htdocs/example に置くことと、同じディレクティブを 主サーバ設定の Directory セクション <Directory /www/htdocs/example> に書くことは 完全に等価です:

/www/htdocs/example.htaccess ファイル:

/www/htdocs/example の .htaccess ファイルの 内容

AddType text/example .exm

httpd.conf のセクション file

<Directory /www/htdocs/example>
AddType text/example .exm
</Directory>

しかし、この設定はサーバ設定ファイルに書いた方がパフォーマンスの 低下が少なくなります。ファイルがリクエストされる度に 読み込まれる代わりに、Apache の起動時に 1 回だけ読み込めば よくなるからです。

AllowOverride ディレクティブの 値を none に設定することで .htaccess ファイル の使用を完全に無効にすることができます。

AllowOverride None

top

ディレクティブの適用のされ方

.htaccess ファイルの設定ディレクティブは .htaccess ファイルの存在するディレクトリと、そのサブディレクトリすべてに適用されます。 しかし、上の階層のディレクトリにも .htaccess ファイルが 存在するかもしれないことを覚えておくことは大切です。ディレクティブは現れる 順番に適用されます。ですから、あるディレクトリの .htaccess は ディレクトリツリーのより上の階層の .htaccess ファイルの 設定を上書きするかもしれません。そして、その .htaccess も より上の階層で書かれたディレクティブを上書きしたり、主サーバ設定ファイル そのものの設定を上書きしたりしているかもしれません。

例:

ディレクトリ /www/htdocs/example1 に以下の内容の .htaccess ファイルがあります:

Options +ExecCGI

(注: .htaccess ファイルで "Options" ディレクティブが有効になるためには、 "AllowOverride Options" を有効にする必要があります。)

ディレクトリ /www/htdocs/example1/example2 には 以下のような .htaccess ファイルがあります:

Options Includes

二つめの .htaccess により、ディレクトリ /www/htdocs/example1/example2 では CGI の実行は 許可されません。これは、Options Includes のみが 効力を持ち、それがすべての以前の設定を上書きするからです。

メイン設定ファイルに対する .htaccess のマージ

As discussed in the documentation on Configuration Sections, .htaccess files can override the <Directory> sections for the corresponding directory, but will be overriden by other types of configuration sections from the main configuration files. This fact can be used to enforce certain configurations, even in the presence of a liberal AllowOverride setting. For example, to prevent script execution while allowing anything else to be set in .htaccess you can use:

セクションの設定 に記載されているように、.htaccess ファイルを使って <Directory> セクションの設定をディレクトリ毎に上書きできますが、 メイン設定ファイル中にある、他の種類の設定セクションによって さらに上書きされることもあります。 この特徴を使って、 AllowOverride で自由度の高い設定があったとしても、ある特定の設定が確実に 反映されるようにできます。例えば、CGI スクリプトの実行は 不許可に、かつ、.htaccess でその他の項目は 設定できるように、という場合は次のようにできます :

<Directory />
Allowoverride All
</Directory>

<Location />
Options +IncludesNoExec -ExecCGI
</Location>

top

認証の例

もし認証の方法を知るためにこの部分に直接来たのであれば、次のことを 知っておくことが重要です。よくある誤解に、パスワード認証を行なうためには .htaccess ファイルを使う必要がある、というものがあります。 これは正しくありません。主サーバ設定ファイルの <Directory> セクションに 認証用のディレクティブを書く方が推奨される方法で、.htaccess ファイルは主サーバ設定ファイルを変更できないときにのみ使用すべきです。 いつ .htaccess ファイルを使うべきで、いつ使うべきではないかに ついては を参照してください。

以上のことをふまえた上で、もし .htaccess の使用が まだ必要だと思う場合は、次のようなものが望みのことをしてくれるかも しれません。

.htaccess ファイルの内容:

AuthType Basic
AuthName "Password Required"
AuthUserFile /www/passwords/password.file
AuthGroupFile /www/passwords/group.file
Require Group admins

これらのディレクティブが有効になるためには、 AllowOverride AuthConfig が有効でなくてはならないことに 注意してください。

認証と承認については 認証チュートリアルを 参照してください。

top

SSI の例

もう一つの .htaccess ファイルのよくある利用法は 特定のディレクトリで SSI を有効にすることです。これは、望みのディレクトリの .htaccess ファイルに以下の設定ディレクティブを書くことで 達成できます:

Options +Includes
AddType text/html shtml
AddHandler server-parsed shtml

これらのディレクティブが有効になるためには、 AllowOverride OptionsAllowOverride FileInfo が有効になっている必要があることに注意してください。

よりまとまった SSI の説明は SSI チュートリアルを 参照してください。

top

CGI の例

最後に、特定のディレクトリで CGI プログラムの実行を許可したいことが あるでしょう。これは以下の設定で行なうことができます:

Options +ExecCGI
AddHandler cgi-script cgi pl

もしくは、あるディレクトリのすべてのファイルが CGI プログラムと みなされるようにしたいなら、以下の設定で実現することができます:

Options +ExecCGI
SetHandler cgi-script

これらのディレクティブが有効になるためには、 AllowOverride OptionsAllowOverride FileInfo が有効である必要があることに注意してください。

CGI プログラムと設定のよりまとまった説明は CGI チュートリアルを参照してください。

top

問題解決

設定ディレクティブを .htaccess ファイルに書いたけれども、 期待した効果が得られないときには、いくつかの原因が考えられます。

一番よくあることは、設定ディレクティブが考慮されるようには AllowOverride が設定されていない というものです。該当のファイルのスコープに AllowOverride None が設定されていないことを確認してください。これを調べるための良い方法は、 .htaccess ファイルにごみを書いて、リロードすることです。 サーバのエラーが生成されないときは、ほぼ確実に AllowOverride None が設定されている状態になっています。

そうではなく、文書をアクセスしようとしたときにエラーが発生している ときは、Apache のエラーログを調べてください。.htaccess ファイルで 使用されたディレクティブが許可されていない、ということを知らせている 可能性が高いです。または、構文の間違いがあることを述べているかもしれません。 その場合にはまずそれを修正する必要があります。

howto/index.html100644 0 0 13353 11237400230 11357 0ustar 0 0 How-To / チュートリアル - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2

How-To / チュートリアル

top

How-To / チュートリアル

認証と承認

認証とは、誰かが自分は誰であるかを名乗っているものを検証する 処理のことです。承認とは、誰かが望みの場所に辿り着けたり、 望みの情報を手に入れたりすることを許可する処理のことです。

参照: 認証と承認

アクセス制御

アクセス制御とは、さまざまな戦略に基づいてリソースに対する アクセスを制限したり許可したりするプロセスを指します。 アクセス制御を実現する方法には、さまざまな方法があります。

See: アクセス制御

CGI による動的コンテンツ

CGI (Common Gateway Interface) はウェブサーバが外部のコンテンツ 生成プログラムとどのように相互動作をするかを定義します。 その外部プログラムは通常 CGI プログラムや CGI スクリプトと呼ばれます。 CGI はウェブサイトに動的なコンテンツを追加するための、 一番単純でよく使われている方法です。この文書は Apache ウェブサーバに CGI を設定し、CGI プログラムを書き始めるためのイントロダクションです。

参照: CGI: 動的コンテンツ

.htaccess ファイル

.htaccess ファイルはディレクトリ毎に設定を変更するための 方法を提供します。設定ディレクティブが書かれたファイルが、あるドキュメント ディレクトリに置かれると、ディレクティブはそのディレクトリと すべてのサブディレクトリに適用されます。

参照: .htaccess ファイル

Server Side Includes イントロダクション

SSI (Server Side Includes) は HTML ページ中に書かれるディレクティブで、 ページが送られる時にサーバにより評価されます。これにより、ページ全体を CGI プログラムで生成したり、他の動的な技術を使うことなく、既存の HTML ページに動的に生成された内容を付加することができます。

参照: Server Side Includes (SSI)

ユーザ毎のウェブディレクトリ

複数ユーザの存在するシステムでは、それぞれのユーザは UserDir ディレクティブを使うことによって ホームディレクトリ上にウェブサイトを作成することができます。 URL http://example.com/~username/ を訪れた人は ユーザ "username" のホームディレクトリの、UserDir ディレクティブで指定された サブディレクトリからコンテンツを得ることになります。

参照: ユーザウェブディレクトリ (public_html)

howto/public_html.html100644 0 0 21760 11237400230 12553 0ustar 0 0 ユーザ毎のウェブディレクトリ - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2 > How-To / チュートリアル

ユーザ毎のウェブディレクトリ

This translation may be out of date. Check the English version for recent changes.

複数のユーザのいるシステムでは、UserDir ディレクティブを使って 各ユーザがホームディレクトリにウェブサイトを構築できるように設定することが 可能です。URL http://example.com/~username/ を訪れた人は "username" というユーザの UserDir ディレクティブで指定された サブディレクトリからコンテンツを得ることになります。

参照

top

ユーザ毎のウェブディレクトリ

top

UserDir を使ってファイルのパスを設定する

UserDir ディレクティブは ユーザ毎のコンテンツが読み込まれるディレクトリを指定します。 このディレクティブはいろいろ違った形式を取ることができます。

スラッシュで始まらないパスが与えられたときは、ユーザのホームディレクトリ からの相対パスとみなされます。次の設定があったときに:

UserDir public_html

URL http://example.com/~rbowen/file.html は パス /home/rbowen/public_html/file.html へ 変換されます。

パスがスラッシュで始まるときは、ディレクトリパスはそのパスに ユーザ名を加えたものからなります。次の設定のとき:

UserDir /var/html

URL http://example.com/~rbowen/file.html は パス /var/html/rbowen/file.html へ変換されます。

アスタリスク (*) を含むパスが指定されたときは、アスタリスクを ユーザ名で置換したものが使用されます。このような設定だと:

UserDir /var/www/*/docs

URL http://example.com/~rbowen/file.html は パス /var/www/rbowen/docs/file.html へ変換されます。

top

この機能を使用できるユーザを制限する

UserDir のドキュメントに示されている構文を使うことで、 どのユーザがこの機能を使うことができるかを制限することができます:

UserDir enabled
UserDir disabled root jro fish

上の設定は dissabled 文のユーザ以外のすべてのユーザに 対して UserDir の機能を有効にします。同様にして、以下のように 数名のユーザ以外に対してこの機能を無効にすることもできます:

UserDir disabled
UserDir enabled rbowen krietz

他の例は UserDir の説明を参照してください。

top

ユーザ毎の CGI ディレクトリ

それぞれのユーザに専用の cgi-bin ディレクトリを与えるために、 <Directory> を使ってユーザのホームディレクトリの指定された領域に対して CGI を有効に することができます。

<Directory /home/*/public_html/cgi-bin/>
Options ExecCGI
SetHandler cgi-script
</Directory>

そして、UserDirpublic_html に設定されていると仮定すると、 そのディレクトリの CGI プログラム example.cgi は以下の様に呼び出されることができます:

http://example.com/~rbowen/cgi-bin/example.cgi

top

ユーザによる設定変更を許可

ユーザに彼らのウェブ空間でのサーバの設定の変更を許可する場合、 ユーザは .htaccess ファイルを使って設定を変更する必要があります。 AllowOverride の値を ユーザが変更することを許可したいディレクティブに対して十分なものに 設定していることを確認してください。この機能がどのようにして動作しているか の詳細は .htaccess チュートリアル を読んで ください。

howto/ssi.html100644 0 0 65575 11237400230 11063 0ustar 0 0 Apache チュートリアル: Server Side Includes 入門 - Apache HTTP サーバ
<-
Apache > HTTP サーバ > ドキュメンテーション > バージョン 2.2 > How-To / チュートリアル

Apache チュートリアル: Server Side Includes 入門

サーバサイドインクルードによって、既存の HTML ドキュメントに動的なコンテンツを追加することができます。

top

はじめに

この記事は、通常は単に SSI と呼ばれる Server Side Includes を扱います。この記事においては、サーバでの SSI を許可するための設定と、 現在の HTML ページに動的なコンテンツを加えるためのいくつかの基本的な SSI 技術を紹介します。

記事の後半では、SSI ディレクティブで SSI と共に実行することができる条件文のような 幾分高度な事柄について述べています。

top

SSI とは ?

SSI (Server Side Includes) は、HTML ページ中に配置されるディレクティブであり、 サーバでページを提供する時に評価されます。SSI は、CGI プログラムやその他の動的な技術で全てのページを提供せずに、 動的に生成されたコンテンツを現在の HTML ページに加えます。

どういう場合に SSI を使い、どういう場合にプログラムで ページを完全に生成するかは、ページのうちどの程度が静的であり、 ページが提供されるたびに再計算する必要がどの程度あるかで通常は決定します。 SSI は現在時刻のような小さい情報を加えるにはうってつけの方法です。 しかし、そのページのほとんどの部分が提供時に生成される場合は、 他の方法を探す必要があります。

top

SSI を許可するためのサーバの設定

サーバで SSI を許可するには、httpd.conf ファイルまたは .htaccess ファイルに次のディレクティブを指定する必要があります:

Options +Includes

この指定は、ファイルを SSI ディレクティブで解析させることを許可するということを Apache に伝えます。ほとんどの設定ではお互いを上書きできる、複数の Options があることに 注意してください。おそらく、設定が最後に評価されることを 保証されるために、SSI を使用したいディレクトリに Options ディレクティブを適用する必要があるでしょう。

全てのファイルが SSI ディレクティブで解析されるというわけではありません。 どのファイルが解析されるかを Apache に伝える必要があります。 これを行なうには二つ方法があります。 次のディレクティブを使うことで、例えば .shtml のような特別なファイル拡張子を持つファイルを解析するよう Apache に伝えることができます:

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

この方法の欠点は、もし現在のページに SSI ディレクティブを加えたい場合、 それらのディレクティブが実行されるように .shtml 拡張子にするため、そのページの名前と、 そのページへの全てのリンクを変更しなければならないことです。

もう一つの方法は、XBitHack ディレクティブを使用することです:

XBitHack on

XBitHack は、ファイルの実行ビットが立っている場合、 SSI ディレクティブにより解析することを Apache に伝えます。 従って、SSI ディレクティブを現在のページに加えるためには、 ファイル名を変更しなくてもよく、単に chmod を使用してファイルを実行可能にするだけで済みます。

chmod +x pagename.html

行なうべきではないことに関する短いコメント。時々誰かが、全ての .html ファイルを SSI で解析するよう Apache に伝えれば、 わざわざ .shtml というファイル名にする必要がないといって 薦めるのを見ることでしょう。こういう人たちは、おそらく XBitHack について聞いたことがないのでしょう。 この方法について注意することは、たとえ SSI ディレクティブを全く含まない場合でも、Apache がクライアントに 送る全てのファイルを最後まで読み込ませることになります。 この方法はかなり処理を遅くするものであり、良くないアイデアです。

もちろん、Windows ではそのような実行ビットをセット するようなものはありませんのでオプションが少し制限されています。

デフォルトの設定では、Apache は SSI ページについて最終変更時刻や コンテンツの長さを HTTP ヘッダに送りません。 動的なコンテンツであるため、それらの値を計算するのが難しいからです。 このためドキュメントがキャッシュされなくなり、 結果としてクライアントの性能が遅くなったように感じさせることになります。 これを解決する方法が二つあります:

  1. XBitHack Full 設定を使用する。 この設定により、もともと要求されたファイルの時刻を参照し、 読み込まれるファイルの変更時刻を無視して最終変更時刻を決定するよう Apache に伝えます。
  2. mod_expires で提供されているディレクティブを使用して、 ファイルが無効になる時刻を明示します。これにより、 ブラウザとプロキシにキャッシュが有効であることを通知します。
top

基本的な SSI ディレクティブ

SSI ディレクティブは以下の文法で記述します:

<!--#element attribute=value attribute=value ... -->

HTML のコメントのような書式をしているので、もし SSI を正しく動作可能にしなければ、ブラウザはそれを無視するでしょう。 しかし、HTML ソース中では見えます。もし SSI を正しく設定したなら、 ディレクティブはその結果と置き換えられます。

element はたくさんあるものから一つ指定することができます。 指定できるものの大多数については、次回もう少し詳しく説明します。 ここでは、SSI で行なうことができる例をいくつか示します。

今日の日付

<!--#echo var="DATE_LOCAL" -->

echo 要素は単に変数の値を出力します。 CGI プログラムに利用可能な環境変数の全ての セットを含む多くの標準変数があります。また、set 要素を用いることで、独自の変数を定義することができます。

出力される日付の書式が好きではない場合、その書式を修正するために、 config 要素に timefmt 属性を使用することができます。

<!--#config timefmt="%A %B %d, %Y" -->
Today is <!--#echo var="DATE_LOCAL" -->

ファイルの変更日

This document last modified <!--#flastmod file="index.html" -->

この要素も timefmt フォーマットの設定に従います。

CGI プログラムの結果を取り込む

これは、全ての人のお気に入りである ``ヒットカウンタ'' のような CGI プログラムの結果を出力する SSI のより一般的な使用のうちの一つです。

<!--#include virtual="/cgi-bin/counter.pl" -->

top

追加の例

以下は、SSI を使用して HTML ドキュメントにおいてできることのいくつかの特別な例です。

いつこのドキュメントは修正されたのか ?

先に、ドキュメントが最後に変更されたのはいつかを ユーザに通知するために SSI を使用することができることを述べました。 しかしながら、実際の方法は、いくぶん問題のままにしておきました。 HTML ドキュメントに配置された次のコードは、ページにそのような タイムスタンプを入れるでしょう。もちろん、上述のように、 SSI を正しく動作可能にしておく必要があります。

<!--#config timefmt="%A %B %d, %Y" -->
This file last modified <!--#flastmod file="ssi.shtml" -->

もちろん、ssi.shtml の部分を実際の当該ファイル名と置き換える必要があります。 もし、あらゆるファイルに張ることができる一般的なコードを探しているなら、 これは不便であるかもしれません。おそらくその場合は、 そうする代わりに変数 LAST_MODIFIED を使用したいと考えるでしょう:

<!--#config timefmt="%D" -->
This file last modified <!--#echo var="LAST_MODIFIED" -->

timefmt 書式についてのより詳細については、お好みの検索サイトに行き、 strftime で検索してみてください。文法は同じです。

標準のフッタを挿入する

もし数ページを超えるページを持つサイトを管理しているならば、 全ページに対して変更を行なうことが本当に苦痛となり得ることが 分かるでしょう。全てのページに渡ってある種の標準的な外観を 維持しようとしているならば特にそうでしょう。

ヘッダやフッタ用の挿入用ファイルを使用することで、 このような更新にかかる負担を減らすことができます。 一つのフッタファイルを作成し、それを include SSI コマンドで各ページに入れるだけで済みます。include 要素は、file 属性または virtual 属性のいずれかを使用してどのファイルを挿入するかを決めることができます。 file 属性は、カレントディレクトリからの相対パスで示された ファイルパスです。 それは / で始まる絶対ファイルパスにはできず、また、そのパスの一部に ../ を含むことができないことを意味します。virtual 属性は、おそらくより便利だと思いますが、提供するドキュメントからの相対 URL で指定すべきです。それは / で始めることができますが、 提供するファイルと同じサーバ上に存在しなくてはなりません。

<!--#include virtual="/footer.html" -->

私は最後の二つを組み合わせて、LAST_MODIFIED ディレクティブをフッタファイルの中に置くことがよくあります。 SSI ディレクティブは、挿入用のファイルに含ませたり、 挿入ファイルのネストをしたりすることができます。すなわち、 挿入用のファイルは他のファイルを再帰的に挿入することができます。

top

他に何が設定できるのか ?

時刻書式を config で設定できることに加えて、 更に二つ config で設定することができます。

通常、SSI ディレクティブで何かがうまくいかないときは、 次のメッセージが出力されます。

[an error occurred while processing this directive]

このメッセージを他のものにしたい場合、config 要素の errmsg 属性で変更することができます:

<!--#config errmsg="[It appears that you don't know how to use SSI]" -->

おそらく、エンドユーザはこのメッセージを決して見ることはありません。 なぜなら、そのサイトが生きた状態になる前に SSI ディレクティブに関する 全ての問題を解決しているはずだからです。(そうですよね?)

そして、config において sizefmt 属性を使用することで、 返されるファイルサイズの書式を設定することができます。 バイト数には bytes を、適当に Kb や Mb に短縮させるには abbrev を指定することができます。

top

コマンドの実行

今後数ヶ月のうちに、小さな CGI プログラムと SSI を使用する記事を出したいと考えています。ここではそれとは別に、 exec 要素によって行なうことができることを示します。 SSI にシェル (正確には /bin/sh。Win32 ならば DOS シェル) を使用してコマンドを実行させることができます。 下記の例では、ディレクトリリスト出力を行ないます。

<pre>
<!--#exec cmd="ls" -->
</pre>

Windows 上では、

<pre>
<!--#exec cmd="dir" -->
</pre>

Windows 上では、このディレクティブによっていくつかの奇妙な 書式に気づくでしょう。なぜなら dir の出力が文字列 ``<dir>'' を含み、ブラウザを混乱させるからです。

この機能は非常に危険であり、どんなコードでも exec タグに埋め込まれてしまえば実行することに注意してください。例えば `` ゲストブック '' のように、もし、 ユーザがページの内容を編集できる状況にあるならば、 この機能を確実に抑制してください。Options ディレクティブの IncludesNOEXEC 引数を指定することで、 SSI は許可するけれど exec 機能は許可しないようにすることができます。

top

高度な SSI テクニック

コンテンツを出力することに加え、Apache SSI は変数を設定し、 そして比較と条件分岐にその変数を使用できる機能を提供しています。

警告

この記事で述べた大部分の機能は、Apache 1.2 以降を使用している場合のみ利用可能です。もちろん、もし Apache 1.2 以降を使用してない場合、直ちにアップグレードする必要があります。 さぁ、今それを行ないなさい。それまで待っています。

変数を設定する

set ディレクティブを使用して、 後で使用するために変数を設定することができます。 これは後の説明で必要になるので、ここでそれについて述べています。 文法は以下のとおりです:

<!--#set var="name" value="Rich" -->

このように単純に文字どおりに設定することに加え、 環境変数や上記の変数 (例えば LAST_MODIFIED のような) を含む他のあらゆる変数を値を設定するのに使用することができます。 変数名の前にドル記号 ($) を使用することで、 それがリテラル文字列ではなくて変数であることを示します。

<!--#set var="modified" value="$LAST_MODIFIED" -->

ドル記号 ($) を文字として変数の値に入れるには、 バックスラッシュによってドル記号をエスケープする必要があります。

<!--#set var="cost" value="\$100" -->

最後になりますが、長い文字列の中に変数を置きたい場合で、 変数名が他の文字とぶつかる可能性があり、 それらの文字について混乱してしまう場合、この混乱を取り除くため、 変数名を中括弧で囲むことができます (これについての良い例を示すのは難しいのですが、 おそらく分かっていただけるでしょう)。

<!--#set var="date" value="${DATE_LOCAL}_${DATE_GMT}" -->

条件式

さて、変数を持っていて、 それらの値を設定して比較することができるのですから、 条件を表すためにそれらを使用することができます。これにより SSI はある種の小さなプログラミング言語になっています。 mod_include は条件を表現するために if, elif, else, endif 構造を提供しています。これによって、 一つの実際のページから複数の論理ページを効果的に生成することができます。

条件構造は以下のとおりです:

<!--#if expr="test_condition" -->
<!--#elif expr="test_condition" -->
<!--#else -->
<!--#endif -->

test_condition はあらゆる種類の論理的比較をすることができます。 値を比較したり、その値が ``真'' かどうかを評価します (空でないなら与えられた文字列は真です)。 利用可能な比較演算子の全てのリストについては、 mod_include ドキュメンテーションを参照してください。 ここでは、この構造をどう使用するかの例をいくつか示します。

設定ファイルで次の行を記述します:

BrowserMatchNoCase macintosh Mac
BrowserMatchNoCase MSIE InternetExplorer

これはクライアントが Macintosh 上でインターネットエクスプローラが動いている場合、環境変数 ``Mac'' と ``InternetExplorer'' を真と設定します。

次に、SSI が可能になったドキュメントで以下を行ないます:

<!--#if expr="${Mac} && ${InternetExplorer}" -->
Apologetic text goes here
<!--#else -->
Cool JavaScript code goes here
<!--#endif -->

Mac 上の IE に対して何か思うところがあるわけでありません。 他では実行できているいくつかの JavaScript を Mac 上の IE で実行させるのに、先週数時間苦労したというだけのことです。 上の例はその暫定的な対処方法です。

他のどんな変数 (あなたが定義するもの、 または普通の環境変数のいずれか) も、条件文に使用することができます。 Apache は SetEnvIf ディレクティブや他の関連 ディレクティブを使用して環境変数を設定することができます。 この機能により、CGI に頼ることなくかなり複雑な動的なことをさせることができます。

top

終わりに

SSI は確かに CGI や動的なウェブページを生成する他の技術に代わるものではありません。 しかし、たくさんの余分な作業をせずに、 少量の動的なコンテンツを加えるにはすぐれた方法です。

images/caching_fig1.gif100644 0 0 40203 11237377775 12505 0ustar 0 0 GIF89aX  %&&+++&'(555469:::7894L(6H'>Y1;G>@B=CK4AQ,Fe3OpDDDEFHMMMNRXUUU]]]IOVIWhO^q]`eLb}ccdkkkgghimqoppssswxxIgLpSkPrOxQzLy~[xkefupXXYZ\`ycwkagfmkcou{tspx~vs{z~΄ێޔܜ֙ٞםܕڐх僳댴㊶댹킶㔹哻뜽䙾钾歼̤ͥԣ۫ҩ٢жƳʻĸȱСޯիڵͽĺ˳ҴۻѾԽٶߣ!,X H*\ȰÇ#JHŋ3jȱǏ CIɓ(S\ɲ˗0cʜI͛8sɳϟ@ JѣH*]ʴӧPJJիXjʵׯ`ÊKٳhӪ]˶۷pʝKݻx˷߿ LÈ+^̸ǐ#KL˘3kg}K& &ͨSwB ɸ'Ei0٢o lѧܵOO`5cV.;cUpw-Md R3F~ɌϭOWJ<}V[?\h`V BjcPߎ @ h`mV ; c PF=e?bhLsA Td`s~'p2IӞqhXh2 ,m Ɉ{S5UeƔa ?[BpFd`߀c{c2n1AnQNa~S?Vd.( dH+ꮳ;^OGC^O; IBy;&$"3JZRQ$%1Ijғ$(EYO &QSfT$Y KN &air%-sa2%)ML]ǔe, Lil6JƬ&5yq^t.pNq{d~u&HԂ`u [u: Zt=޺z':1r}T1[HOvӦb-1z PtS@ `@b:1vZ@M;֡Y³@ zΣJ}>۹BKL9-2t #D(?w΂V -~@(Bjԭcg1)CB@h򥬼M`+Ow ~؃ @W T\~ .~@H_ETBحf{" P @e<܁h(`PE9"g[(KQpe/$@8.d<&9uf(DNPhNI .Y%tlǙ#1EC`'a GAm0?}:4$JQ. @=h@ w -PǥA >RLC8ĩK1%=tzckEþ-o(X9$DARر*܁&ςdֱ&o`h{[Yh#D1nC $ĀZ pw65ŧ\;!в(NQ 5p<-8tWv]=衎qNo?ۭw+AlT{>J x.. BB'`q!pD.&`hOW67~[JK}c \ \[i~7-Fc̛ fa7& 0zv8~zgS3f6yK&^a'eKdoxtA'v|!!" ppCa~tp __EeOw9 ` >G<Ѐ@  DjlTUQdeWdփDzhofzqQ60b6S oC eSc9{F q' 砄AS qӅ 々LVZt c:}v jV ip@ Cpx`*o C@\{eX5W^mphpH)qs#3wԖVqvo p 0 Hx|KF !!`p p`vO1cLdk6_4go6 pjj0|t`*)R lP[6h_8]SVAx ( :K85`ȅ,TRt]Ń`u{ 6l]o :, w Whiu]_L{PYq_z (  `C!_0y7[Q_D  gzj HDiըX_`P aczp0 G׊x!!PI^S)WgW0BeQw0tB(#t~KXaSc*MIE0]Gq}[M_Rh)u@ ט?AVUW0h|Kp@ g P1i8 ` r@ӧ@Q^X_UwpVqXƙɧ x0F9QeWyh^GKwp @w yzjY^8^R`ah @ Ç '" yy 1\%wvkCvQ X8l~Jإ P2 svj7f?XNg `R`^7k(n‡(ixoIUhX5_OeeP zE`* p &W7HXp: >w( dJ oC 0 ~dufyh"8| g2]_R& l(#P G Э*qY@yev{ t0jڟъHDzȀDЋ4vYwR֛ `0zi"A[F7 ^ss'wrws'#[0 pӹkxywqp@ZwP| J9=S-@yp3b%eqzڳ*wcdQgsv_+ L) |ɲ$e _h^cWv@ q* xD RY 7]Z{`{#|yo+[ $U3LP c"Twk,qzfjpoQ xvk7Wsw^Qpu7e?kYquQɛ|)řnEqpvg[V5ixik-e\t[( ;aQY| U^3{sr)Xiq7ܜ&v% xHq4< p9W\Vf%SZ:HA  fpR! _B|ۮROp+`ϣw8)*O`&v f^6{IKGŘLtz qq]w 婩Zb0{ I0 z NE@m{Cw  l u[\Ée4'Buύ,XX9a}h7+l-IŒ {}:S` *79ӹp&Y  : jP` KuH 0^=ƪXi9GYFKZ sF5 v^B|q`xQk sP/p%.ʧװ~pX}{fֵc!QWnҋImLՏ@ r@uPZP_Bhsz?uXck^OokZ) ;XJQu}ʉ  h0{N&sH΀kQhǎ$O xKЏ (7P v:XIO1_R=ߢm+0_i h$5Ǥ{WO_~>t1C!^D;VFD鯢 E_?yAb"B8hQ5ƔQ{'ÌNhSTUIaHYv̂jWj*);I RD.=p" ,*Zc Ռ"PS^p1I4=A) w$//K3e (|(E2qUyY5:=&wx $?p*"(!5t_cK9Ynvz83=HBV3d-p$@fGvy*mGȪe00!܁Ҹlw.wuu.{k'}uRbS.𖱴bE;1&ȁʈr]%_ձb|N@s50+[/[Hn> Z+:nrDԭVx qs9El9W0[J"aȘ73a8Os(0RBq Bu2B;A8="8bP)d:6mB\ q%nvI! `'Ue/u9?v*P7:+ܓ%Ä5hY#ݝ5M4mb7/1{8f#cR|2Lġ-Zjݔ#9\]h:3y|7bվyef43ډnN0 xI V+a"@ >YǽUy T/an jU5S庳]u>99|%?j,ryg?A B4KrʏW<$넎ԉ^؟-!H=ax/|<}q >( +>~;}lׯ\yzL,pC@59 ܠs2BS@R.F@;Iˇ('oRd-Q[Dc"?ߺ[&'@j1:>˓r`:"gLC+> ?VA6ԠCԨMɊ<DT3cDƉB;9b@5"hؓ3kZT U_Ads@1D$3Eb|7䟥{Ba%TLdCIK<@AtBK=P-i c *ʃU?n,EdGF!xK_$c7>Gwƒ\ ,F=}t~$8':MS?FTȘɇd4$xoǯjFﲿQ-dǓly<˜TSGbOLCEb F a$F4r.&x^87ICA+ɢd~]FbJtLHt"zCsxIlJ5$ɡ$[:%J$g~+IMlpzƒPsdļ2ʡJu2& U LG!ZGa!XL :4T գ%xwK4dn<+lwr!DC FR̶Kqd"HTpIL$CL*&(JTْ/v3O޼@PZH/US]+$PJmOM]~K+S6UQSnU-hI-T ݳ4/\T)Lu`="HV8 J3RV8Lg]q1zDV{|##+,VJ4&{.D%ZX\%XTXW/ClցNΕBXEdS+[_-YiOxЅyX,\+PXl~_U < /CQж][(!l5#w]9"0@0t \ut⳪?LvUs]XFm 50ܴuU{X.j0߂51?7sZM(  =4:]?О_ _QkRe[w)`=6%5@Eu-mx\bl `%^Aul[-u.+//M@uW)xsbbq0](xxc[y|42wYUq#aF226.Ѐ-Hy (e@zw؂i)O9v@n@5)؆-0-e23,X9lQ cc(8Q eP2.wP~(4؂zg 3-y 3(VL^y!nߡV 2(2w8 P fcP *@5P2Pf0c.Ї3Ѐx@Xjj( N3 ` .c.x52P,Wֿ+@H0ǃ]f}xz P (gm.eЇi(e0@bRˀ20 02g0PxXk10Ԅj#deaF-mBP͞1K.L^4f}@4~iނ.@kl*h肐il&d5@2@c (j@5ˎ:3Zk%t`aI>j-.: wc60zЀKJ3 } j@de0 xvi ?~jZO`'ЄvXoJmf8*:.4+ (}Ȁ5 *Ȁ0*+ #i0 QȀ?#zf lyp  3>?ɇb}q$NX&~b q~H AW y@A'4 G @?E l S4|}qql$b"_;c \˾{kPWL7'ɹO O^o Z8CD$>Wչ+Y0SwvpnG+3]fOs-ZhC4RHϟțɛ!!mnVoM/,?P 뇥v)hk󸃱wWZ (y#׀d8@+ jHr") yj(i(c5 ؂-+8w w`iL."ifZb_x ߔO-Ȁ~0 0pGjP5~i20jW  X3 y4(w(n(zPtP(>~ȀTgedQ@h{ac ҿ{|g ~ nPȀȝ~0{+Ȁ2fWx0p ؂8 ~524Xw1u!m^}V(hP1 2lp!b$!ƌ7r#Ȑ"GI-Åh%3̅~W&!f,2,˟ٵ-D5: ː4P<%`µSA@)Ԧ+Y:R>Q .}4`[asAA+lWUCxWHSAxqjP< 25nHDx2?)zqeQ@IkIKbJ[I X@P'_zj~5+SN'BHm)WI<`BM護<{w{^x;9?S.y]wIsYgM1.>F'f;; ?<<Ӯ@v;!>髿 `v]R;LA{3_+`V< 2| #'HR`B! r/@j @EB, 8CBuCHԡ%(^3:U mI(HC#.|Gγu͏$ sl_ ЀQPW^  bKgUEoAR;F0$5Fq$Tp Vq 10(bh*c1p pJB (A GM)DH!Րe92#A*( a /{y(/b^3̏#ßy>jRd7 5͎P:¹}X2Å v^Kc /qr$vXl(GQ8t#(''wLVC T]8H>"iS$ 3VI6{b E.vMt !TT#B?2c3ꤦf%BUCY"+{wpb^@TrEVNYwaEEd0zQ*V2D+K'+-!ɇ: ` SkMKi0!mPvyYF ="I>@F2k5V}B*uùa­Qj]@CSF CMTsKb=>$T}n^O~p}}cޛ27NҺ몕 0IYB/G )Ap Sx$͇-`h=")z[p !--My =a#E tRȔLd`8$d1/if<ڠM#6͗('. z$5=0W!1σ=]AzG<֮c.D6l,+zY[N #کTwDjj>#Ж1Q~ F(d |_CB";td8 h_V!kLa`?Q~9bco?lyי~Gx911pC0~aAm=F8t>'oUS0ET-C>`1-?C 2?pC:C0؂ EC-G C}I]^C샞(D0k:`=Y0;' bD?*?-:x&ÑCXM`C1E~1>+B܂8:ܡB '(`'Db8| a Db` `aɠhRZTK.T1BC-:C''܂% ʎr"(?@b =8:DU A"xы/=|B0=p!(=`>"v 5b8C 7t=`:%='>(`>CZW⑞/?YLYV>iP-!%yE5T; `Z[8NlΉWDdF%J"b?DZfkZBlbDZf@.D{m!kN^5_cסY90zUZNmgF̑HUC &fyCD;'yf;&c' {u^/Zy>ݫ ~n{W%sB:V6~/mREp}h{M]f|b%mޓΌb F|Z F+b2rSl&CD4-B!.PMEIPi]eTO/@)?-CIiCi;)[iC{1AITYEu9B驑(L2ix6XI:A䞤>USFCe}*jCbYUL6̥Vb*JxÐ-yJAYBh%y &:B:? Qfi'j{z)nӽ<kƩ2%b hT,8"bkjU(BLJY뿆S],,# kΨ:=SNlŠ8]ټL2[ CcB뼶jݫlbB&ޚkzS2,Af-&lMgzӹ-%ʖ0tƭ6!ޢl)F0jl-UΩ~lqJ-Vn8 *!tFbI[E&f-6Ȑ\1lz|0.H,*WkJL/(6 e>k6RLn*?8 n6%Jm%Vk=Rm~2źlB-'ԝo4z]Zۂ lѾ=HD8,V.b/_APFYɯ=l<<6:1'/17?1GO1WW1T1C/0q'q7q11q_EH1 2/H4h@ $r pPx"O2%W%_2&g&o2'w'2(((@E")r+/+r'2)+_ -/20% dJ4 t]3;3|4a<4G34O54k5W36{6gsAl8w37938899:G 83<23s >3@s;33s5Ss:<t<:/;4E7tEKCY1;G>@B=CK4AQ,Fe3OpDDDEFHMMMNRXUUU]]]IOVIWhO^q]`eLb}ccdkkkgghimqoppssswxxIgLpSkPrOxQzLy~[xkefupXXYZ\`ycwkagfmkcou{tspx~vs{z~΄ێޔܜ֙ٞםܕڐх僳댴㊶댹킶㔹哻뜽䙾钾歼̤ͥԣ۫ҩ٢жƳʻĸȱСޯիڵͽĺ˳ҴۻѾԽٶߣ^\ pHYsHHFk>12IDATx T[םQ,msŊ]` t;۳l3IgvR==G9gPyqlg`{k7J6Sc$i(UJԵ,i8͡ı,"}}6}>~}[!3aY    & ,& ,& ,&LXLXLXL0000a`1a`1a`1aRD+ӽ؃J6 inuf:|5ײe`ͫvn$1X%u@r#ᔼJt# AcG]p8DYrlX3ʫ Hra-t:]0/q'n۱v݃@ӈ\]jk^a\/1|mcb{[aȅ5b, ZDiNެsUk$MT 6hj@ hIۚD6j j@Ĩ4VkM~A:zj\Vu’A..%tܤz\K`IW\j<V=|U47ׁmh% ^vXDi^1̹.p$+u(`a%kJJbQAC6B&8on})0B ͭrKU*/dt1Wv{H6%-W.hr"9-&E ŭMuI&x 9dt摆|6iLRӕ?5ǟɮ8&)Xk1q>ׅĵE-ѯ ?qxWX+V^/9_W)V},|_=[ZǿjקdsUkV fVWR{P5sWxS%xG c/< ){o{S9L鼯Xlb *1a)& ,& ,& ,&Y#ńi,&L *00XLXLXdJ$#čl2 GCagmrmEq 춡cg E;u!\_$a }vPoX'_p##vk/u?odnu_WbFahԏg̚Tig`ݴ|xz@OT _X7/xhp@Ou4"\ÀsU')|#tTR7=o?df_ZhP F&TiO}nbϬijW{wQ=hqEOxCi Fǻ H⣏EFVQނGݼ?k | pFcyE[O3Bp62 K7ukpOQ_i eGWj N`C;#9oMCLL~ =m)cpH`Ԁ*Ƣx-hin<'j̝4*K+⡵4zɧ{Ni6]#kžС.ƊxԀ9:knOPu`)>zh7l; h)8^س'yb``<>u0=NMnr;<)ot#D 0.ㄊ}m<ԃfxWl[Z8.M Š탨O(xv}]GNfr{E18Tf `mpަ{;;w: cƓ?fԛA]Jah&ž;qꈢC22G;jwP0m}Gp`#mܹcGω* MB" , n eFp6A⊞ى}Σz3Xj~>ET8A tA؀*8qRlhi>ʁ菤h 2D6<6#g>xhؼb Q45 LawSNܻ'rޔ+njZO.p NNVOQu({xDr멠D7OkJ{jF=(cw:yRSء…B v;SZf G?SGcSs1ja7MhS B M1L@Ma?yہttPʊUe]9/`$<Mt(>L9ZE M6Y VwTUorm*wO~yp6nş3sPFK &/I1tu01zL$ i73pm 5̹i K :` / {ZJrO_84~8n z`@Q˲p+O3zٖ]ˌs{K7b7mǻD=ŝNh>:]kgYr]O8 _ħ& ,]Mw3/E;'pS/vr0v{!(O|hNr˘ɇӹeP=dpj~Zq:Aѡד5x4 i}iO%tኻCz` 6Ht"8pEGvtEGˋRO랇8Cm9H|1OȴbOS.v҃H_>e`)%Zk޶Pϩ'=>u}Xp'K1\LŹ T5m;xM "WN7D 6\iʙJ7jLw>POzk4g*%6h>9cPU6+N%r=߻ʜ8?b`#֞+|d4*QڗgWJ>zsdIt).Ӹ>6wdOQz6c#XcM/p׹{]Ww<-Bc^YOR Ylvh AqՓbXr- 8ދchlp *6.G*X{4)ܼǁ;M!TIoދ wUsd @|صnzrhсBGҥv0N8@B h& .Oc)WL"KP?+ύ a=*Tqhb0%wOBm@87\hہ]G0_ѣxҽ' 3 V-Y[:wB_UD 6j CKc a.=YnV`RzAzZdzY0:2KCصW:Mɤ06 MJoqCi締 6*VE#\m9K^8P>4SKv!`ˮU K2VCPۧQT`:87Џh0)듌֝@<$"iw)9J7e%zm\|ޭ6qLj`SnX*EPbw7nL~Sc]1+f|<̞9sE7XyO)b,{9ڶ}͡(y-|; 9ZSRn7oYL=[vw}}kvfuqd6~!yWTëS[;rwcrqIqMm}ĝ s S3fxmn5aAWkw}oUТӶдOCfͣYw7 b'Oq/~;n]s[ΚL+k?ſwܮլOnκ;W_ojr>ş\ < h2}AjW:VZ澪a|:r )Y~1￿o?p緿U]S߰F9U-pd(*0[|[ʴ|ܷ3xyGi $cĄe+ʾml}|Blc.s ͑u}a\t;6} HDȬ#cEFm|4zg.Pƻ}a׭2m9_hE{$J !6iydCLx /1U7W<֍.Ld ԕ/RfzX7\qX1B (2Z $)f1EVIFΦ~S۵/z VZL!kNipmt3m 0J(f U@c"(wq݄Rۚ| =|PW=t71d)RVAR :=AR<`EBv݁{G;䞗XS7zڡ;9}s1+`-pkȀJ0 bQ!={x/+ofI 7* +{s(^" ,RMiλAI <2 y8,Q"7  : o`A 4>¹;~$G)LN ~uyu+{4&}Kr@8cZ+c` ;`ÃeZJ¢¹\-=<[Wbpr"\l 5Lcy}ٶ ? U:Bخ0 1NM<֬Њ+=٠_brPր59fm{XZnI؎~7`˷Ae$tC6h,܊7n;"BtZX,*9X#}+b`-:Rlg20=sABk ld|5l-;݁ Vrb +,lQȀ'{hؕЩX(k^}tYn`y!<迋2iQoP!0TnHXxDY6 N4XaIqǿv;tGcrm~,YiujDe e X(Eƚ?*LMHD3W]WJIgiWO^,JZp_X+O 'ְa%װf"!/e$xĂ <@VXO3l,DXEa=,V+$I;ﲓ+X"s+(;'tw(r;,"`-4ؖ~|KkסZJfLh0RM*X~ky 9qZjpΗmC0["y]Xs†{{ɄԼJ'Ů,Mb SFm{di0f oVFU;#aC?~>4#V2wk ɾٸZX1xˏ\X,*L"XՄd"ySmp윉ky,~,F}~S3YyO߯ZP[&DY*P{C e-ϋ캳FT Zaʄ~<-!ɋ)6VXd߯P`ՄgjBe>J;HCJٝkY)q`jB,lW |e >`}G nxw:P[5U&Hvwٝu'J`,DXc9'ZሥTLֻlY`Cl:X2oՄ7gf]:Xv0-ZWH(X~;pvMN2\rkۀJ9Sao䌧خ5˕4X´+dMCP+jBCũw+`4+ `fR VQʄ)F;8n3t(,V!,LK25`eCTEC< EbQa2?,0pI0l5w.BŢB8gh eś´^ 'ԀUBDX˻8|:M`ZaBWw7|1XTT5jo|ErAUBMDX)6]FFߎ0h]!|L8b{rM}_{TBRW8yGvcky#La{j7t1NXV~&(˫awO] Xxñ$bQ! 0X0`}\>&])d$ȝ Sd Y)+jW0nMnzzj=Z~ISP({uokiSKTEUe+X eݽ hX,*4Xw\zzvz5>Zj{n,7UMT8^FX%Hj_J FJv}r镏M`%f u?:X1f ao<#֊BME+`DX%HkuVVֈ̿_B5%55s?(`6KX]`FEtMb\e6\(1^TJo4mJЉ:ܰPrԙQasUMfsC'k:f.дvwquW5um i,a>P YzQQ65yPރEW[$rrU~cN}9 uś9MiǛcPK%0ʎ_i+ LYyyN#J"Z`BNDEՍ6~IC4S(7j۰qk׸S/k.7-jJ!%o5&I,݀W۹{ߤ&+ bX- V w3(XE)ڜ#z0NKvjEs f\DT)3qHWy:$uԊڂMR>u/% ˂mX59UyVX vhA^Sc)X d0WhKuUyjЃ쀮kܲ1P55[$gUc`=N|3@mqܳ.D̨eW5|O-B1%!i #vmx*b`I>꣰!em~Do<$kŏ(KXRE".󸬞~I+w}me9Sfc@bR [ji 7(+AOBw:bҬX 2_E)uQF(;rVXH̉1dDcE m Ѣj8ǁȹVYfug>-u+WLO;3D*LaxW`e1BhpX J7% m|ZI ҰCo|!,ӧ_64r55rjV SVV)\%DU-JUHЪy7m$PcYu/?RQYpR1A8h4]  +Q% /wpsrXQEN Q%XzO?"ZrdޫVޢZdGTm< ,z A%G5콥Z]`zs~,UX(`A7mJȽ 4V{/(VCi떵ˆn*`19mm_[},MώR2 {~D'XXy*_al% tBh`-B V.UƎmf`1+`p_[cV?N!X$o߰B<,bny +zS~R_G"CmИ^xl$o}3f U?n6 ceTc`_[3+rPv*`1=`LceR5i45EhLy{Ʀf 3j ~e`1}! `;p}VX+S`͠ ?&SHb룽:-Ma/3Z >lZHuީ~XG7%u m†7j,V X6~ãoK 4U~UJ doIu0`}H+X_Wn1RcM+_!2c ួ|S u&]%֫ǸƨX4k=HC/w-}L1X_+D5;zZX0S`Ϙ,|k "C{o}mD-Xl]auGhˣcy Us_[ tuj-aҢ_y+=o4fBca_ۊEVhШUZYs~R ՛D|m۟~-ȴW,#JNq02+TtJ~[f#mVxn+o|܈' ۹a#51},RNwQ? ǧkǑY/0sjX^gGKY ɟ/ɛP¾ܙtP8zmfY egbQa&5ܡx.?£BMᘽ+e+{AZ " `Wk Ӌk(`c{Mb1mxSHBtylrbغh, M/~w',a7%R V&-QXiڣ°Uw\NŢ$0X]E LŻDCi/~|hXgL\ۏ22ևDžMߠ,WHBE(זt gOA1zQmR VZȣW&' ߭#,[ Uix{Ni, W /#M!K7QIt+,٭! oH(,/>yqlUbE贃~`|V`7* XiLEak%ŏX2 _,vq&n?M3X^?~v^WHXsjcg\,{z5֨e(5pqזJ!Vx`|9,qѹpޮx:+c`љB~[%BɄEkˇc~H]tSm b~i+r_Uڃ+L њzuo|=b&Yw+)\t:W,V+L3XVΰ VƄ;KRfM>>|~&k eB`͕+\YK~f?VĞ%y>W, 0Y,_bdAnXLXL b`1aIXI@bӿN==o~"?E_ԣ?kyyOߛ7=?[yz>`,ӏ?}ǏiYomX3Opc{fy1;G(6HZφpXۂv녱噾ږ4L~탔4694AQ޳ҽc׫ҭͳʺ˽ɟgܤԶƕx䣽ی㩿ٯյu둷789츿㝝EFHNRX>@BѷsUUUԥ]]]ӎޔܴp{왷١ỿĢ֕ڄېwxxkke&'(Ig\SkIWhIOVO^qPrLb}Ox kkky~Lpwoppaccd҉޶쁯imq]`e 333䓔ʣ:::DDDU)IDATx^ɪ0 aλ!ĐJ`CDW3`l$((kϫZs;Ƴ˚/UilV{ɱ<=)1je%9b9+PXH 5X -yvjsƸ{Bâ5R[>uucy"!Gk< +\b-rYa?{U2z)RYS`~NMja(MA?ͧJ߃iH\6H>g_!E. @Y,7` ) >З.?,VNDǙ=%Yڻ ޮg80E;VG(R,~<+Vp-^_!BX ,ڿºٹ6+_ҲBJ*R"mv7nZ(I+1IhHڴq'U!߫@3Q='`H24vr~g=+Ӎ{VO{՞{. . ,A0L>nDl1mA h4Ym~dz},}`,U`b ;]z<9xN>4pЬ"wbDl k5Irۺ+("=VJΠ-+^~5d9,NP$+i Λ(gt4M½'d,p%MҸ^ⲉKT 1("ݗov P@Sc,6E&'=W~$t:cB79OIOUeMg[?~'~9di>d@D#NO<^)m^[ux)dbq]Ew5ƢF 2FM QMґX&Hoˤo΃a!4UdXlDR-wڌ`¸Z#CR.MVjgF ^etW- -\ lv?~7٘t9Fe9B+of$hM^Yf,k@Xn;lHoNU<hKY7 9sΎ͕@R-zrɲJIPf)*"}tdzCbE)4vyIÑ\ "DEN| ү ;)U!. $שRc<XOѐs̭U(6jġ޽Uzh~tCnQ#hZ)nPY(4i2i\>* .OeÑ=REV(Яݍmkl@$(o |<UDOZK $:4zvfa6VO^av1[  nhJ P);XU3(n *-[Ӛ<(Mp19!ơR icf@eLhcǧe8P-Qƪ s두ڍMe*X,4},&DrLB{X yOhN6ҘL. 6@hXobPdd]\ /,-3b C80ECNÅO4am3!puIU4f(ˬ_Ghr!zdQSvK3{xTpH^ri;Fk6umg`5SnU9܌>M}W f\؈oo!kz+Qܛ)Tb&38g C ܨΧ5YͿENә|>rK>LMNtw>Mg$>36w&6Q / -=t3KG@d*B1ڣER(~4~otILw'S鏢=6} iSs!; L/0{) {9zj,0{鐢O_A #4+~"5Grn<3|ҀE8Ȅ0j;MC= jm*lOf'@ UbD6iU8E翞DYd"!.ށm7 'ֺRB4 "@FIUz,,g!J k ,%\*f %/J)Ā ^m?4 nP 5qq&fT,M,/"QZR=Nc,Ad1 jc<5ƠXPKO'M<>֮.`m~8q`M ,pxY1-!B,ߛu7 SIpK Ӝkk-WցU)Ʒ}𱊡`DWRe{1#vC=1[SelazN ,N' ѰG;*Qh zwb\;BY~N}wց%T+9؏ܴr7fxͺ,M! t?#%ILK*޵7X@V{XFG={WRtŽ7inՆ<@37LY:X0ѼW&XlCwoU2QRyhb)EU5)צw`PY (PV8{CXfqϕmi6dRZGuͩf1(k#ƊӵH`"l:GD1M1ڑPJӦ(H>njxSwiͳyZRgSӃYSdY"KZ:|]N4A9uJOV$eMu0D>yF#YU?kK!΍; [ŧ p^R )@].:}VtF(m*Rg`񡏨Vuetڙx.Ivf2]밇"n-O2kGX, [ 2FyEҁZ M/hZgGdb=%`<"ezRWwLXlM(_bh~bn'{{_j-+oX:>56%~y ˋdlvgm"hw` 5djAŻ~ wݢb8o&lS $hŤ%,(F;`RqshPl(!{=K,:Q< ,Cv:z |`ZҖ* v J8gny 9K^^8hO#Xyou{}9bl$.oC!(b'ȻդBv*5Z>+ԑU]l7 _I|Ie+Iǰ@X ahÑ:s[t# 4Z4;(4  Bk5>sJ[c[9aE$/qP+`XcSCW Sw)lfPDjt+ ņ)B>(h,n˸U"P6MT8[ǰ睤9z ٕBI*rfgYM4V8+ CN~Hf%tK8n`>",T/ALmydlzyVYaCh[XS|RгMڡE}"K(+22 XSZFy?R q>OdO S ŶXe/+~WN<B5."|@cWc 72V) …_W+l!/ 9)o'~?CX@~ >|)m y1;vh 7ޡT0-lagOC*}^c@z0֤ѧEo&,ftl)·3;ͷ[?,T._m L v{'Jzp04sShN /"BkgiГJRqx‹e@":kR'lK_) ትmIշ?{ ZSvH<׺}'!bXlqitmam7WDxγq.R^>bb(,z'QZ\:6`[ s(w.:tp6/jTr6ͻ@+ߐ^AѸZ:>(`2ׯB8_Gz xiBM c6I"76@'%r-2-HCI͓A5+;R;2744W8lY}?-q8%2{X@FZgVx6{}y:*OMV$=CUcjzۨheωc[b-2B%vbU"QH&wI)Sx dɢY2SN\3ѽskjpm߶ˑ 3`G&*ߠ0T5U}58_kr^Km]6+Nk0k;K̬[rss}Kxٓb!$ 2%St[Q3<3>)ظozQ`ϾըFw"q X: D%]aб#$f{].z-b_J]0 GX"xRgWP,RR% Uuv+? 76IKŒKBc o.kRA>:[!ȻsZuP᧭} sW̰'Aޟcu.EY0ݭR%PwmHz`8ގ}r"1wx8or ^aG9O}lo+kO䝼̰\WE5Va% Y6Fart}|.B7a4gZis,t,>0Rv/o@ EfnҼ/e AGXBH\.tBmXFˍ+ 0Au2Bʱcꆹ"r!ĕ":mp\] CqYip2dZ]_V]MFBe\R}!Wx `n-oGB RBD9γ@\w:;/(Cz}!Wl7=%yǕk FZ-K(^xt, aq.UÉl`VphB iM4U+9B+`'Za/=;2"$5se/Ѿer ` 3,huV^@%}ɇ HwRB б܃7_/=jx p"0xv %NnH8ј{|; ,縑ywJQ5*4 o `h̺{.aѻ+|e r}a'xT~qI If!Z‚/֍ŁI Ij~Ұ? I(3k.Wȼ#ĢԨ} ,BtP<ͬ^]0ˆuJ1 U-cz*W %S:~h XtF쳼h i(SX fX" :VHMḟB;Nb3hX B '}}]u,eJx.aJG2֗V|4;#&7@c p'KW]8QY})r+C#:7=7, [Y~  ǧ4#{\M(7]y?3Ck|xEhɤ/.+T4Myv_hS1P AMha&0 ]OMZ/Χ %םIFb;!^ Iڞ2>~CW6,^g ac ԵڃepcN)QM`ϟ^P$p)7}Y:V8"`ٚz@ ^ϠS9"a _z*G, \{,*J:QK=Xm|"`gZ-2r~cD`n;-w %!-p 7Curb49Y_ccKu+ b5LN  nsj!NBq ' ҁ1QcU zWos9V6t& t,Kb j?"]>sԏ=Fy{Ho/\MyoaiFP\ X=,7Ehi0L&ģPxls7]<&%3RR!i5q'LwXR$J:aOtwp+~'.Bt5^bfֱw`ew[O>5'"n Ta$籚]z, +;Vq=zC.Bӡ[)vK:e_oX#yVN?OӍ5$kW%b VBQGIh}quɺj K,z^l~@ cꍂk"ִn(rS+3W5Q`Etg2#?/~@f')57&F\xp |%P#18\M `{G=ǺB12  cI8ݹcqj^1XރGj,{xY+ 7FPm3Vcywt`6$Y+b-X5AI}-ss޽2XyrsޥXF5.]) wVd|~(a`λ"1֜<XjR)XBZQJS7@:XWR8<{r,Ɲށˣ[/נ⮌8=B!BiHAٝya=Q `}5f!yw@ Qf@E@O`-BD$PH R4^(5nZa}:|SM<̗tBhsmwEF֞; 彣;{hR.v\롰PJS"t+uXw CQ5#Z.,NR}YtS\|:9Hb@#D,xhAXWx3rnN>ЬB^PWXKI]\!ebaU(KO@CK2$qU$P>?W$DT,BwUV;1*I]>7PW. =e.X4 -~i; -, Y!ƫ0u]>4̰D< ΢֑B!rgXEYa<_*;ߧ#NiwX1 -aL3.A٧+(CEHB*4LO йI%ِ8-L~JP2Ah7?ƞ> ^MGo|gޛ бk,U:z& R*-yģ!Ky,UAgAH5`)7士mh~{'}oLW;c>ybHD ?7{g`)dx^@u^g ߣv;Bdp|`AnH*<8Fo$U+[bc6 aQ?bm1GN75`ĿU!a/i`ez,Pmf*SӃsQ"(Pc1s䰢(b(azh:6{e!bjfwe\a-R P= 6 n& G lX˅T[:X*r z@]~1N.Jr8HLْl*EkX. |No+TFu,}go R:>Xa,ْAJ;t, TISU TX[g?)LBb:p_! B^!|Rψ= 1ül B r;T := `ݠ1<\e`r: O7bcnl ͼL9cajU])Dݴ4zCf?_ln6 >VI|BBH ;N;/69_~`u챽Nj;H8D{fjKmVXcI8x "(4=Zcyǒjv,PXg t,:xw@NYx.?P6m묱 Ցǔ_c9-U~Os 1TrJ"w%#>. J]v}O?coH?9J8LIENDB`images/custom_errordocs.png100644 0 0 41417 11237377775 13626 0ustar 0 0 PNG  IHDRWsRGBgAMA a cHRMz&u0`:pQ<>PLTEqqquuuQQ}}0ee릦00eeeϚ eA42h M/jn4=*_:Z1cWsrE0PVܼ*.W .`ۂp6}2+h0%E[umĕ;Vm0l+Ƹ2l+B7Y0,g[]4m %q-s`?gn__U{ŰO`Oȣi|Hao`2s`[]\˔\ BTKE '3pt{R7X{v`[]\ fqU5 pp-s-< _#%V0S3q/1=xBAllZ%Gu{*EMػ/h׹c%;U 3PkV¸wZ*3F`lzvq/W@Y$ i4dV`ƕqecc\W6ƕqecsp`c[mk[u68*`Oʸ6Yqe{ ]ۂ+[Mpml`v.]Ý MlC0$w'-Wi8x5QaWtܧD)<9ٸndք9ܠF}oGTGG8Uh`N4z+\' gtkmt9ٯ{Ɗ Exc`GvDž36d/[[>>zP Y ŕڹIeo;RgFע~+3q:tl=n3z5N+Ck{:~~(!r@P< ̊]^_6@\5 OUØb̸4+ia~/`ebW03\ &zUՃ5=Cɋ|M BҊzg͠KlkAk.D\1յl5ƕllK W6ƕ&R,*.ll_̵gub׭Ŷf¸ŅޝE*e͸Uĵ(v52fX ;baR_fƕh}м.ҵX@:v.w6yҰD+/rp5Zd^3HVn|-76 NY\ U׫:[HS ׫ s3\76<\Y;ڗy;p3\wgfc],6RRJOcnߤ434u:Wphݽlc#0 Q]xMg&`F]l4]VW5߻O۪z,xX: 0ۭ㪻k&Ph>>BͲ : @pJj%+]J ޵JW_ X|'zf\V̻4(}s0Fk-vຕ5aɋ]uURveqgaު߽kGY΂+"S~FW#3 EXa,pLp\5,wMcY*t]5m9 Wl\m^J㺌cY` /ǾhQM `x/|Es&8`l+ɣŪIT+ǻdzGGALfa@[9U#Y }l}M. q}-So>k8xk-d1V˻ d:DGd?ǮBn`{l#\r{Xz;_L[FYDh"rQ4G5A9Y `wfhD'wf<8Py׾wE^G9ֿdkU XfւQ$dr1AXǓ9yHlQ(?zBYaEʲls9֣Nө(/Q=+cZ,v#墦wdykacR@8B<|:kyʲl7=.uBtz=>DΥ]1 @^Dƾ#rUY,vâutMm!O9WjN0$FE9bW` ~F?1aѻRQ/i-k6,6A"~ECcD YHUZ,6/ⷔ̚N~:F~W\HNTM0#ʲls޵uqۋ3{Z$dW̻RWr؂PEczWbY yle_Ư= TjIfDr225v eu8k!bUvڷ^ Z'V{%n#ܤk!bU\ {%)Zt:Z#L9qbC+^ʀ8OM\Od g'} *,`ߨhH//ޥvO|.M:T$h̲l`}U"U+|md,"`/Q TbY 9CR{ګipc_ܭ%e`9ho뜱+bKYjP`/kβ'K؉XZx+ƮS ˶lSiU`_c%x:'ߛc`[z*jZ*G$bY(OԦZ-{l& =g Xsby߻KJZ=`iR$d&`2X +g8)cYf]0Ԁpv# |1;bY *֗IQ^B,:ؖK`GI{#Xm.'[ڷ 4/3ޗ}"W;NgGpyll:KN^].uq, n3@1r0,F 4sXt{YĚIq4*S0#YP{P5Aص,F^IUd1 }06U^\%{IsX򯗲@Pu""9$KZY 8 /#P1P~Fwnl5I W/la[>ud1{5+h% .X/EZqql բ./$.3$5ûp^x5{a\4fK$Ꞽ@dqkVPU@VxM׊yJw5!we\9 o֞HMUVm@~F*aABZ]شTʸeJ"혥ɔ4u?գKTU]U*lM9;nH3Gp|,XYE2u6q":K¿pH_JA ksT;We1~R7gBs`f:\}2 %ͷ&4t=؇RuB*v(a]*eQ '.,U+TRWX%]a@yן{EbpZg@u{YnKX ubiH-@Hyy[d-Po+״{^aSXJR}8|=&X1-dzͲlEYһ^jmJ`лX \w>ʲl% vK1ޥι%(šC)]ѵ &{,[9;Cw5Öߒ6z_Uczߍ[Hm 1M@]Į+[Z~{'N/3!󯊠渧GIZ RC5L֜+b0Bd2K:R \nDɥQJ;nl6xrSU["hCfPUD19]+bU ZNx'Ѫn?wXBi!E"{*eK4Li[,kRJ'D?r+SF8`# n8WE/}Q4£t4U^_)o4բ^g#*WҘŃH+"l50&g[:3l wxF`e;,Q]Gʦx&?$1e1F48u";ЛSN&Fk@7~Oj(LӪ*#veY ȕ$P͛/Y wu it-_OQc"X\d1]STvncH\u^R7rtǓnu" JQ,4o4) /!\&R!\wd|B*Xs]bS\#D:L@>/DWR=SxDY$Mݐ`&q,He[ˎ[t|HbI\EX] ȔXyZUz״T(B:՗\DĻJ*U; '5I9wZRuDG5_#cb܁wE(%A&,A0\5rDhl6!< 2#fZV,FyZS֒ U=zh : %Q^/-aa ]Ss4"'IK:+4fW׊ZUd1J*LRElZ d[Q1_'c$/=P=Hk~w*vU~UU.DO#'?H]V,F%Z3\=M]{ wNEiPvKvRȔEi+{E%ۑpͳbT5b N 4l{[ S_#өl[Lށ+z(΢ׯהWG=s˻.T՘n޸c-i`n^Bp*EXw~;@)em 6$l])W:J;Ve1`@Ut:%qe|N"NixQ> Rؕ@.Fg*Hj$uѲ\Nq]i Ov"1_ :8~JC2UҮm3pY@"K8Yš.%g+6wo(Djѷ'o'd4/9 >'-3̉2]K0Z,F^VKe:z#HxK$1pjiX̶|:!=F@g:ѲG }ꋞnڶJ]!7@& t L<- NͶX5 P:PX!bxD6LA%a).UGTeߩEI:,v]1&j;=4;jNC|ؕTqh0P@:֤mD&n:x99cW`3o)$zJ^ Z=bU.'Q3n#s^@yױ:wlwEzh`Q"&Ud'rk-˩,*mV+j,[h/s{bu4v{p$]ʱN+neAURz$AeʲlESGGTH VHi+ wh.גkcdUǰ -ĻȹɚY#9P:Q'o$Ǫw6)cF/nqZ&x9W`sqD۶Pu@AiOKH*V5yՑNLӮjՒTV ,[A0דuZDQ aOcd)aQ:iv$F,{%i!JzQ$>كX J-zIIްi$l$X',  8@JX80 =H:m`VbUueY EĮo1ъm\OH0EG.*@auĭi;ج(E(kbLf0IcM?w],:d6 KJ(N/@ziH Pts$NusZsƮ `[J5ޕe1]Y&ޕe1j+bɻ,[+b(veY eXޕe1]Yvull`c[w],R3%e1VŻ`c[ص,F.O LOzo[;zB [9in"BŢ/"e1|rݝ5ޔ4cWJ!zصUWOh 36_WυUBuøړ\wmx=h &]o˜1a[{#W#Z"_!PJt¢e?@v>U;rȸ'aĮn檘BZ}Bk{5_DP=<$-ۑT)ʍ8&]}1>jLde"W`B;wpSB}Mu` Us fMM Y.?pi*p萧5'Li/]o*d\*Zu` לPWKP؂yd1>:{A ?ى,<n@ DB 8cXuВIpoc}̌<V2q1Jn,ìž.`"v+S!. %&l}t+ §]-ʸ`˔X +W`weY :zW`Qʲl5 ,[-+bɻ,[+bŻ,[+b(3l5,Vص*Ů+[MbV+c6d1V$-a& a}jwhKO,cA`KNG?F; $&4fCq }7-BCehANJPicO75pgVGMot*BwLp}o7v]SYX^];"dv+aחo %Ay}#}Kq\X[YtWW%%=d_]5{.-~+?azkue1Pϯ^{J(ʕo^%:6qmٹޞw]Yٳ/_=¸1N?OuJD$Df} m_VR7]WCUgD,"{Eľ/?`?&.?_ !a m+Eyŵ%Yfzue1b*)_=Ȣ|In}#Yyz6ҳk+}7;,ъe/ϟ=K}lY}O>9f 0YN?|sKvuň1F3%V9^RK"ˬ% JWϾ.b<À =!K+Q?9ӳZ X*(pEf dˢ9ϟ{G*>!lQ??ܚ~|LV׿\+9>$S?ݧum˸q ){W}!+}NY_*gOwӸV\ Kf|Q"8!ǩ~R5D#~A Wd^Rd!\*{N~߿ Yq۟~|JNM\"P..ު.~Gu˸ꮯs>Wxw2u?mbcr[\1SWFi?o^?5VM8lp%zZJc;T‚+*{}O3[VۻMcXEpyV|_O \%ol^ Γ2=@zt-lqi Q) w Ye ?*e\*煱Zg7ۏyzEwH,e ;gVƵ2&ٲo?j^p`nV0RLֻ~)!OsG8oן21Kk#M[;>ep}K?]tۏ>ĮX#M[WY^;z(n^qk|~gFcg>~U䴏_EV]uU߻,F=gҴsL~Uޞz)wUh<'?b*\,#$}V۳ͻ,[MRV,ۺy׵`[[ﺖl,zfVmb=ͽ/ކ= PLŁ\MQ9aDA2؊9TH;34t7& .|]w㷦!+xֻw"Ԙ g Ff[S ,Έy8h5gC<11bNxɁC1%xX[E[#`zGd1Ho &p6Mɘ֒QWy/T<ML/-rL=[*㷚fɜ;~y׻ŀtHa{RWXۃWLokrjL7c^ A9azz:uַ~mp; ܑ,c; ۷1D)#VWa'u=a^ٚݼSw>`HF@-Z4~z5ŀ ^,Ÿo,Fbwl뽒`[`bq0vK޵,F,/`7ȪrɧElCJ#/8w]w6e1jgޘe]Ak^fUE# >Q+J(gٚu#bX-w*}pkZ:TŵԑCS G%@ ׍0e1 nFYR$-k435WkƎY ̃s7h\clTE6t!d/a}4`k^+X:ݶ_ev3Y Wcdx"k&8Cf+q xmD %c~ܨAÿ JX*?/NK^*XhhqVuϡhp..Zlh"d64G^{6{BӍgpZaЮ  ݍo3۾e1Vm末[ _Qpwuמ:rG:V9WBJt:ڦG~>8Fw]bxc:ٓ!tQKfn+ks_+ՕW`-yŸ9bzw_Ӱ:\-紖w"6w+Y 69kiYNfZGZLz?`tqҟ}3aT#2e1l̊v ?ZpN;":jUd1:i-uZg.Gcur}%\zgk9֎z.Qu:}d.5Cc3n7`cz0wl*RV&bYt 3IbW쌞decN7el$17j \Mu\S^f5w wٜ>Ů2UX/D$:GvL,]yD:~c/Cr =Mp2&=amo&."k'󃰣掰W0Pdx3݃5VʡIu!TüNԙ}05pu~.: 8W@:vv}!MO+lnnY Õu´F׈:mԌ;v<[z3Yx(qO&4Vl ŵj0* eٔD;A;;iw: ";6̀ȯv\@z03Ϝ[ýXdoTԒoXuj1V1NBLb,۹2lV`c\_n$vwV`c\Y 6_ [Umٸnƶf`c[i`\jguVႬZ$⼕BdۺU [csʸ1+znoom*a^Ͷ|jv&֖4Rn7Nn3ݻ%mڈ]w-X|i֌vvB*ƕŖum6f]Ǥ2Ju[ѣG 0õk2 Һ+v"\J\7%.Uؔ T8n7W``slo6!\%];*џk[Jfâ5부Op 7D.DIvf2IJn7ݶpmZo,Ƶwkƕq v[y'nJ0[m]Wӣn7vȜX@J*nqdfʸe9n7)%qc׶a2^ūZs&dnBwD{W5'3lbu޳cj  ūvNymBB+4we?36V&i M+vmv޾ljZg%Rʸ2`@4v?AﺻMNng 2شfIz%Hٛ՛M^0)c#B B ev6l?p9NlAjLt)ddLM9|uőVTncj4,p0H z(L F0+a\@|q &>N#Pp} {@m%0)hA_$4iCpH(8@E@pd^= R: !A 7&.+ '`(̒$.U $J0Le`nh;)%8!Xr8l QE( t@*.G8a\TΡ jW \3+J0no{ۀ`WXSYJ#S[%(o1Yn4; Zf̨gV D) .D~kܧ*-W 1 `f@XUA)J7 ZU,uiV+ۗ L4 )%lb/ -.hYB|s X\Pm3 𙳙hnD+ A T5A`ѭ.Ce33XȮ˱^+ npMw8XtAp4!.sw_BB3`!'mP fm(07,+X ^BJT+hBgÙ pKI` BМ'AD" q<(yp0=EE;8j*?"BЅ%ha ?G QH̴ɏ{3@@~uVF ` A/'Ԁx Kx"H³`lK²(WmE=q;wPc ڞhAoUԠ'Xl@ @# ZйqoR畟́eu&uT |wŋSjz5`E+TnCl Tuo2)!)X/RLk!V%u6>Pez%+<@_7pyA5GBO.j7OdwB"Kr"2P7(.pv~*L.b)Z+g6e\wR)77zRlPz+&-pBFRBPF('!!A-EU4ir&"9"P)`",:E|4NH8Q5QV:c #AWW1}R{#+cX}+30 R(rrP0ȆA w~2Tul&2W'84ug/mᄎi/o"YSg%IBy9Qg0`d/P]6A0;cFQ^-R+ŊA0Rw73E/cUUdB P3g.sr/na2PGgA]cg8u5`bQpuAs6:0AW4M;Ǐx+7c81U /IUYOYkqZceWi1hA`E.@!p$ggML6•60C3@RrÓ;i,%+}X3pQ3]#9+8ViL" RVm]a_(@U:&ިopUcP^QW)ZP`)dL0de`! =GL@XP|!>!{yi^`A^ePVp$3VDw =Yq=E'ih >nH4ptdv66>&A=!JFa i Q-lZ;%G'Eeg'yu?EY`GS``ah́K o :oY"7YA<MD@gw&BjP83ˤKwXS m#"U CdW×0rZ3N(a[y"\b/_ۡ?QHa?C6*u@1:8Aql ZIQrn"#P1?FP"?ƩG'P*%SbqQbuT' kh-Oʫws}d*tp$:v֮gB2,g-PtO)šLR0OP 5#!6Y[Ŋ:MCB\qE*`;h+~ۦ,d'-;5KrH jbJs}Z:@5vJ}NA[, {@@!@Ғ"3RGZmY`FR.AHC@TFi胢TBlmu{D)h~ ,2'G(;(zp=0nEP\n!rpp0U䁤KjÆt8bt4xk,(zn{OGiG"v @]pQPQnS4=[@Tc{t/@/q<:0NRzRWE8oR3pmmQ{(;(ptPő'.rxQ#RZErk6һ` Z>;)y֤NU͆g[JgWG bǻ~-p{S2HC&*w $X`nfڥ4`GIiV&aUN`#u":I3Ie] Tt9cWvkOQ;"F+Fj/" Rww@c>J}#k; YIp8v.@&}v%;{m\n(!rX!e[.dw&/4Xy^cȂsk@`3:dg!׼wր±=P.pu6,2'%;KBMEq.h&3r_+$p~@RLQbPigdI$r%Xm"+-@h{zM{<{pBd.ҷRv7~Y5$M@rt`hs>3Lμb}& F׆]篮4vhuôX"b{%@F,ԋw{`UT/J}h:ea9)\N=nd75ª(AӮ..c,ª)'oi!aSqtR8!B2:Z+8L:T? yW6`7Ap71E"[uIGƣ,,pRF,iԴ'wˋvB31Ј"WT/KSۗn"}u78*RB8m ?B&.vk'2=vw;h(Gqh12=({.VQ[ńTـJM:ZW"0_pI+|RUfB]'zG͒"8rB-Ⱦ0^UWձ@L5?eU9` E&Fh`OPcRd*5UXfx"孃Yq(H TQy=YGJ3/ԭSnYO:g1`%P8H}Ծ60`/pX R؏W}7-=.B2E#.,θUX xy=,2$ Y/955`ygMc%ns70BfRþ銲X2;iHB")`ұg=mqg[NqQ~}E{)?BX̣&5yI W9VC󳮒,:&hS'5)8 B0#7/*`HX2557gt8jA,4%__ꙥ/10|]bXZNmuI:w>A/( c;.6v5i7D9Xr5SzCg[4c5XI0u偨ހ{ @9e[:dkD+CH\;ɫEN1ŞR]/1UlP~88ko8s_ Wڑf0n1qYxx;6Ņ;Ya;!D hDAA .dC%NX1&lQ#Gp$n( M, )Y nTPtME,ȱ"O:. , A8||4"8FDEyw3x F 0Š+HHqE -X ]򸐴'9PȜ gI$G=o'n1,ťON< ;images/feather.png100644 0 0 13210 11237377775 11636 0ustar 0 0 PNG  IHDRFϩ<sRGBgAMA a cHRMz&u0`:pQ<PLTEoO5p`Xo3Pps/n6KcJ+ 3PnVFw@qU j :O+8 2$r)7R .8Ѳf喓mi[|}eCCCX7QPK !!!___..-ppof sȣ㍌w츛fVЃk-3"ga^r3͊Wմ@֒ee_xay)Rz?n7hDf8i6[Gt<`3fT# pHYs+\IDATx[_ZwU䡂"<},Ȣ q7QScfL3}wbjN,;I5skWvmn/?osp*[Eupo~}(ʃYwU;>=n]=qKj>=>|ݾ8}ו\wܹl'w*c;k݋Ó~yy;dsNWljijfm<٬]/=}rC]?c.7vnU'tzmsow|{o&3>H,o"@uѬmƵK^;ǟ={n0/szzzl :^QO6O67?`*?txx-NsـJFfF6k:hwytIk͛ܞ{rlYWO0bvu$gf"6k'AۭKu=9Z*(nnlG\]].WwLw,7ӽgSEؾ?< sKsMȺvڊ d~ۿOBv:/oȐbJy[/.R0q6 ̑ښvݢZ5e^yZ?h5Ѳ7tWntѣ-WiKaQ@P:fWWƺep0ef EK_`GAh~Q]䬝dg}}}Zouxi=8Z;Q~~W(7,me=bewEmX/.ӫ9Wx}'޿x_De]ZKJV놲p+V:ռNs(1Z¾ko{#I ׷PDsVW{5oNDFcˁͭ+w[Iw.D+ R=(d#]"zNf,kڹNF{7_D|J2Laz6K= [RdNG'K_e]^Y3-,ʂjZ 7}b1r=^G}?Qtkm7˓{ e*cAui)gPw)zk7lyhdyTӁ}>ݓ7w={2´Ş]#yfc%H&#ZBqk"qtl7@]NO&ÞHͽN~pVkU*GJGMԹ;̗9ZG$lH>Ik9 ¼F'Yo@GQNo7Gz}q~z}Q' #UY|[Ǝq5u0lt (ioFY3vc~ } _FN48C;k쟞7/jrW-Pl̴ S}3|gfOyMt\Wzlb]+ utz F7S$qW$5ggݭ_yb. ZUsf,.X:eZuk?)M^M$E;U= Ց{ xת{_nG޾(WِZKr}B+YPk2d2x tkUeawMkttU6j_n d'Uß|imZll?Rtfq[mtvP:?ʰg55bѾhw51<XuC,m|slx{ZDm?;kkw;Ϗl%C_2rv9å-)jO0i%ȵ`E _. 3f?n`vᚱq㤆Z?:= Kr)lA-j!dݽ![AXuIG1Mk56=2CF*{tLQ1<cV!% ڥs I二љ$6f,g-+뎎N//NSG BCh\X͞Xʽd'^R5Ӿq.W]4Zv^p80墩lSKpS=+O`X]XęNw~')eV!;uށq[bhlZ1a AuFWBpd1F~x>"[PzcZ~"gnRm; фl%hB*A }3t˱CsI%2N MYqmӍs䩩p77wÞ`s*ӂ^z]J5st4!GՎ jlZ2/TnEeNqDN+,hWo~n/ֈ x&'B!,#}<@-wO5F(|T "`oMG%o~.e=e'>{O^i8!t:KVl\Qؾ|.kp_ 9:^^dHRfS4םk&xo;SU $Rs R0o: ]G^wX?eS Jr _y;FP#Ԝr["\%@s3Z'dFq Z2+<{oC rUD:Ч9tl<`ۍ%-Wy1u糬 y%l47>fQ@G>2'Ȯ*K3",4.rS=?3nI!+LW:y:lNspsmBƪgr2TD?gZwĻWBꔙIg4'd"Yo2W#2'dW ?[xv0q$0\5CA9#e8qoYk\D[[Ojq1V05\zZTl3",=2KiB>… b=me,_ԋ*!$I GOIZG+Ym8%yvF MLQq9GVܠ` &e)s8P!ɇLùj[)| 9.SOrB;^N8Mp6Ws.w0ھxH_xMr$N'6рZ("XtL_gKi jQ(^x&$G[~]o`P] )lu a(36ŭ؂@&*b7 a~&sy_՛>_e .W:} 3Eَ Z jt.+J܍[rUhAkgԇ3Fz00>6FP7&^|>$oL֌ % g|,@I__~]'fA\$뱙sIENDB`images/filter_arch.png100644 0 0 4553 11237377775 12474 0ustar 0 0 PNG  IHDR9[ccPLTEU~ IDATxOLxɖ5HiixhU`"U&C[岇,T`I0{/TBJza{qDH[Ro=*^o޼?d3}Yw{{߿7!IKZҒu1.#31z45O~v/f$t}@]AfpjRcFwڹlF$F@5 QɊ@k%G 2=P ?=^<̿o(C}4 }uPIu-ONk֏Ƿ7s6[ݜ݉ݥûʸ5VxiF_U2/샹5h-nF#;О9_>:bsAv8ܖ֪d &#Y=Şz6ֿhb}6Gխ(=z~p2Fr' d3UH^q@:-99?:nch5n7G]ƵȠ[OJ6Fu(Zp@HK Ԥ]A E$Q(+<ۖP *}Oi=ګq,PHR%C} K)Cۣ АeXB^d\d) ӥKA!O˺d4~טc |?Ѹ\C$bB#64Хw~ARټv d\uTR P/!4H7(@[ӉD@ VF@6HH,- #@_9=1:RHgC.GPBw~@G&d?td (ẕDdP}Uh"l(H[`&@9,"IVDt`i?#h̀ﰆl6^<E#YPJ@ (%74z*a/ N1^vEAh5: )C 'eGn+{JqeI'Y$WVOqFw5.sM"w n8/JqAPa\]ܸb]u7?9rAARH,W_cu <Y{2PO yfZp[P!ҧ7/" ~bI遴);R|.ϑR"G)w]^r'[#_)2S?b=>\q0?崙wLdS',"=Ia0AWOc'9 ]-@m9_lӸWQY0x?*PdVP" ݥvl^)a}~^.ЂȤn6p SlyDܕR>boe?[JԉڑγPZH!Q`jeT[͈NF#_2[HCXHR=Squzgհ24f͖%<㯕QԾw/lZȔE2;R\P*Ծ=h_#<102VwTIz`mZ kc dt.{ *~#XWs Ұf^}Hnxr6(ZxoW1l d_ *brW1A}XtZLگk di"t,v RȠTw)Fg(h.'[oeZEBݮC{tᧅ?~f=F_4gˍBsv36p,ZŌ i6Q*f |R9 ?PcڑZcʦ@Oaׁ _7wA%&nrQ| F(dΑ, C7Wt/b3h4G/yAAIDtABj&NW5i"iE, 4 {6ϯW O ?~+#/@Y,Q3@9,P /" `>5DȰ_eQ@ ڹH+^)_ ɿU (sWԑze $@ "̑d{׉臭rA- `T̯7 ؂ (8;7Wƴ~h.jZ&6dCGXn!ђh:GWF B^:O1Z]?JhѪ1ՇīXVCժzFz:I@ (%4?)03IENDB`images/filter_arch.tr.png100644 0 0 4706 11237377775 13120 0ustar 0 0 PNG  IHDR9 PLTE333ffff uIDATx^ˊ:`]A ̋VO1+ж!zC3KVުOg*¸!)3!T)!=3=3=3=#P~ ͳ3{DsWp<<)' }G,;=sAez陞/{/2=3=/+3=ڇ'@{f~pځ6}G)G=y^^hOIcA'3*E_Yh)K:U?3תLT>2-ATfZ1Z^?YH#T=3V\ΊcHD+RgG8Pegr]<ճ@ēґVO䜒~zNÉ)'-/?Z.B3 +<Ξϙk}Kis~#!ZWˁIJtsqRR|pHy {S{{b4rnXyn+Jֳiǹy=u4(6{h穃=Xc:ˮ{G9_{υ_  6V P R๷>U=ho w ? q7lPXHE^ʃjOX0>xl1yD(uQ)XL=N!n"<=y3bx,2x!C&գGÏ_#=N[ /"Xe)^ʣCєҵ0O"@<&rI*ߊ%-Ey_u!4sSxR[dG6Fz.BHbC=uQP<c=(s(ςS q婈kagg>?陞陞陞陞陞陞O`Ͼ~Kz)@1<ʫBOs(߀;hꇛmn Cy*ֈ6-m?_#fU$_=N:Ϯp>c{Dìy`~_ofP{/陞陞陞陞陞陞1ezgz gjoIENDB`images/left.gif100644 0 0 74 11237377775 11057 0ustar 0 0 GIF89a @Xq!, iLre zJ;images/mod_filter_new.gif100644 0 0 4530 11237377775 13163 0ustar 0 0 GIF87aK,Kڋ޼H扦ʶ L ĢL*̦ JԪjܮ N (8HXhx)9`yyp`Iũ@jp**ʚZ1j Q j뉪{{,,[ -Lkz<[ ͼ l^=ݠNOڎo2.?/@]|5",X'CW+Z1;z2ȑ$K<2ʕOֱ|Y%̙$ҼI!Ν5e!С= ҥL:} uϨ?Ri֭\z1+ؔbǞ,k6ڵlۺ]mǸr7ҭ7޽|l 8 )Q<bXGd-yVqo58kVYg5)5 ~!Wa5أfq:k3Lz+^rp-͜'FFzÀ)q:}~YN<8Yh_wƩ_\~x= ,qX _t7Ӑ=F[r0@#~"dTc5wV=,IvB_[iR ##Aԓ9H& ydq=n!O"˔TN`\iP&*D)m2'un ʝ`~فI eA.ʨajf4&*%ʙi2ICs'j>-*J*hˍ;{Wkj[0l/תحZܭNuB[jӶB HԴtTSb}c,==3um`=tBh03Ŋ#966 gh &'?Umw|pӝ{lפn/p¶ ޚ;»;1u &B<YRF8\[ޚx҇+?^$D~nb '6 }ZfOb|xd(`ހƫnr[R.m~]`8LcOx#CUP#;Gg73,uA nHTY7* EYy)+cG14\3EvZsaFF8ob(? [`Hj$fcHKy?Yh2,,)OTR$ d+'Wr-kxKEܥ@ LRVf.iL4cpM%9aS61C(}\8YBhS\`ʓ[ l'&ቑrlȴ>ǽS;H (@pĜ;Jz6%G:AM71X= љȹ` * CI4ԁ?ЉnbD>e'~++5ӈ~p_UHP K=GZ0SC~a';cPM8͟ґi:O7ՔdM=F2(cݫX6s #3:Pe3[,ԘW#* jZYL)լ7qqZCe;;Go%mT*GFonRS.NqWi(׮9* MhZLM4IGDGnF:/Жtieˣ?Sj>9~9u^\}U/Ú\5dlkJ. =Leڨs\xˌ9ojXJr=m.g7+f pU!6뮨ywt#ۇ k~_\5nW`)~)Ci8#䐹ȃ}rۤ+?p˙\3oN\i@W9O;B0zMb[LNTK}Tկk}\׿}d@;images/mod_filter_new.png100644 0 0 2034 11237377775 13177 0ustar 0 0 PNG  IHDRKH"PLTE1=IDATxNAgw4&.L;&$zEib+#4V"510фYQxD~ݒmw62'9̜ʘ1cƌn[)K}6J1rE[B (/1%)!PU,yɰ#׈ڟAq;*9DJt- fy{YdgF)FB%eGɕ IQ냔'` 7:I0 rH.K!QzAC S9B8 +U甌v/8JxN)w9z+-9N9%Mm99hF_4WBM51\^t';Sl{a"UE؋GQQUԣ/b(N%6wbI5,XWeQs4+mLosbH8̬geCCCyR7_-H06|8 *7z.AT8zv^ tE+`Lu+~M=׵)A[T5m1YqRe(J47[P?igYRE9 ^v ߖ'g OsSB @6FˢMJDz K΁֥;"be̘%?¥ IENDB`images/mod_filter_new.tr.png100644 0 0 2456 11237377775 13633 0ustar 0 0 PNG  IHDRK PLTE333,/IDATx^1n+7 <@0x)Ҥqb2УlJ&XyZBwE?`ªn2(ʻ Q  ^JT/_Z>(J(JR >919$ҺGي(.pe(ڃL@KQ@%xϋ5̟QS+xFUT4J%`G+ëD0~1QȫS\ Da*bq%ܧ;m&Pv3BŃ|"$ .۩Ɠ~8GL@Sn$Dmj@~D(~@_Ost)l_>t骝&_ lNKE@:ӳ9&U9BAB2TXA#R% )x@w&0Qs_u)QQXD'BFr( b 7N7>V|3N`CAo2Mt1OFVTAu2_8s{Tr=T&ro~6U1(y.U7ķSuS^F VQ9H8P P&%wuN 4o6!$*b|CaEQ)[̦A<*%g1"i灕JPEKtJ!" NBvL\)Dg[R7x̧ \0pQ(c*QgfQӦR|%RD/!8!N,*TMy T;0;}h UQ&5^+PMώ(pa(O+Rmgw5.S\t};k"+S%R,?jRkg"vVvVvVkgM)֫L)J(N_ՖYmH22J0,+UPMHꗋQgS.Z÷3M)*eP.٬.Sv%h%ba 8 pڽ)SRyMJܹUjQ$ t(T}SWJΫ5lj~:1<#JS u2%>Sq*C "XXg o=hPSФ"SQNQf6Gw8EǸ6V8(h(Iy1h))JyTDƚ ,nTf>ۻgmn?f<&9ԫ[P䃖~Ut_}r_?=g H`s\n " d҅ n7.z!tJvkbUAYtv"q9Ȉ֚-"$θ&ո!h g4tIwe`XMiLEHIeyH#lBd`㚈0!%:q4 '*bNg`_ʓ&:袒NLX*ni J8Zj:*r(w~z\ jPeR6Ⱥ+1vGlM,ڈm}#yȏ}K%\r~2r^B$.fAص7kֲͶȞ ,3{Oќ +q qR"*lL—r2B 4̳r/sB]/?t's2MgU F5?!嚣9]uaMI^si6chӎJwqm6i7;mtK"rwH&-橱ylgc6Y+ŷIyq!fr{;C[biQ ?B/>{/JɹG-2]>*;L On8{`#C}~ax2h۽67O ؿpncr@$J15,Tm"-S/ jp*;images/mod_rewrite_fig1.gif100644 0 0 6705 11237377775 13422 0ustar 0 0 GIF87a,ڋ޼H扦ʶ L ĢL*̦ JԪjܮ N (8HXhx)9IYiy  jGzږ +;K[k{;ؚ L\l|7-]Bm -^@n/?ONmߝ0 <8-TᴇrJ9i#vבG[(6^_$7LFV`ִyg![^$["km)u{큺bM@50ֻ0w᷂dW"iqaG. 3vNxb9!֬u\NyƔu88ɗ7E͸c.6eТ"YxRi7Ԫ{e9|ʡd΃l!yfkXVpY69Rzީg^e(^p@ fDl8{gX-ƈo&\Z:bv"QuٵEbSgyXq}d_PZne^~ fbIff)h暽f.py˜tb睳g,|f_JhG>(.h0ioT .c| **"\|6jƭꫢN3V룰JJl3Tˌ=笶F.n >.C\o& o pLps7!>o=gF/gx/~ᗯ觩`ǟ[دC¿*B " \@,@0,lR>(t FHl [R"P%@^H򘟐@.# ,:$*s ,qTLbC< Ub [B,(z+ZhE2b>BaXŏGa҇x$;Lz);f d`ʢ(d"'g+]HZdA46$mʷҒLk6tHukiCrԈ44z:9PV2&4]I9@/zRlg ;tj(zLBrĦ>C3T@V6Wf`D:'H@le(xK iy{F)b<ʀڈ3 ACJ!wj?=I HIQQ8"NMKU>t@MpRE#qwrȠ4Tj#t ғB)c5cBGIDźL䰭K#$%N6Ȏ=jRal JA;+ &h*eB [ϞI¬H[&^DP\k5ad~IKo+vRq!7K˕oz,5Hui\]\ٝvF]Z껻.ț\!7  u v[/ x<+Xz| a88`roeKJn 1<  şP2 Ş1h Ʈб1x 7 ǜ2؈ #&p$ %ʍl#YR#dn9];di̘(5+932/;?Fc%|b=3S썳[ pc>=&NU6(ĩThD)Q>Ɏ-zOXt5)iqV)A Bqq>nf׫~/dWureMhG$^u|[ N3̲'k=t{w?>h{*kgTԋ>}ex>нOރ͟iOgv?o ?7G_ 6(@`J 2ӀB9-G7f7+",Fr!*8!X6(x.d+#XW‚z?3v#'rFIC6?ȁ+ C893/4X+o\7 E38KӅql|3w0&Gl$ɑCtA(9@yl:)iGUin REvyRiB"JxboRbqXV钥xPnPNE%hsaEBɕ+;xIuٖԴ?"Mt1vA)x`PqL'WNi_ uqɗGk`v3R7P{PetTy9nvb%2'Fb`1?P|I RI%RH4Nf'v!z е~) ^-} $2 E?jŀC_V"x=?8 R9n'pyVςp>ZjZj֟:lwg53ZjZjZjMbߨWoTVs /יQߨׅ76ơE{\bUoő)7Rz[m5׿z7c7,9Q5Rc۷dFձ1P86RoߨSoǎoD7-coZjZjZj5OoY/wכߣ6}]Xd;Ǹjk=]Y.|z<`-|UgXe*WsXeUl3XS[?~٢Lc~]o]37֏Һ~-֏Q:֜`Q?vQsGt]Zj=ƱZ5yLa:X;kKe,\:XL!6q3y_8v,O8hM8lM8hM)j=-ƆƼZjij̫q1ZjT箈${IENDB`images/mod_rewrite_fig2.gif100644 0 0 4771 11237377775 13424 0ustar 0 0 GIF87a},}ڋ޼H扦ʶ L ĢL*̦ JԪjܮ[8L.gΖ;PS89u9x'LJ`8F2)3YxHpi`zziyI#+ !W L iKiˑY,Sk-}z|]6=@fv` !|~*??=ïP^{i.l %gC!~*yH+@^ƠYh@R!ԈI{D~pGćK kZӦh=r 1RtЩΗ<<֎&EI֡f*ZUlp@kvOf$'ݧ^9MР_j\1?AymPhxi%2砅{"uahG*زԥ1)D)GG0o}uao<%롖H_mf~=|!fZC#|q`jW0@`("we 0hnPX{p(b+hb$" (046 :Z` c(^EBdJdG>^^eZne^~ fbIffn)%Vf fl)gGig;g0g%*hjhLĠVy h`8ʉ/az)[(-kb^)D.]%eLYT:hjZ̝"\.|fNJ&1gj-XB-~GAʧQF3.y~I@S_>O?w"W\ V*5חnE7Wq2g/ae]&_Ce"vՙG+u7΄ǹR]}&KGlݽv0mqtOe!GXr)>|0_o_ ln,Tm\K5BV jt4d-vF[c5v Hbri?Fiւs/ I *uؽ.Ynɀ?Њ0y+fۋ.L/j'BDᠢP,aVo9:f~~_OcwA߿E?{/ M ^=8` *00E&h"+i?@ODpAP! _pb i8C8|G цSDjL|`&J \DE?pA_DP5 glRAP61*s# 1\#A@6-`#vd0HB|@"C  $y4rCL&/TN,'UJ#AL% I m/he,kHDj/ `. ԥ oY "\L!B38&5ghk0,&YLn9TyN5L%c괄¹xf05LVpUis$d8) BoL?pʳ<>UC #<& i,Zxv9|]"*-:*QLֲBå NK6ҙKO|KCHgGN 4]F 碌'O&MMLzNsnՎt2łu9]m:g7A 3Ԯ/ۤe=jQs};6:UgiC28Ņ+Z pi]̅KW͆0mժnͳ6r{b{ VegSֱ3t{Ul\q삎Ekgɺ& KE/hs{Cs Kz^Ҥ۠:eb'`rEn*QHjbC踯X-T)ؽåNUؖpm(Hכ,$)/qHF``q7#׀_0'ˀ^p+]/\ @-iš,qZM{=wO?ԗk+oKԯ ;images/mod_rewrite_fig2.png100644 0 0 2545 11237377775 13440 0ustar 0 0 PNG  IHDR}$sRGBgAMA a cHRMz&u0`:pQ< PLTE`p pHYs+IDATxM<* M/s{GAmtV~ '' b?=*n94@4B?8p]w)OynlrّuϮ@Jt)g9*p|_.7\Eb rPUR=QxQ=J3{\c4<j#f38R?Sd@ffl+ I)FaqVڻ/8. ԻG(3pbٝ=qQU9)%;2pb@'C 1%fvkVZZ`;ۈd/5;-YOlѦnٜYԗX*^韗.7>6#]ϟmoצNZ9y}=[`9*ߓq}'*Q is[Z7tsή]vŏ<Ễ1/YKzk~wyg^z7[wY:8{wb'be`Wxg[yf`f(F݉U0 :FpJ!;HԒ"nQ8l6h[]-Ȣdlyԓitu[:W\|V'~`Z|gnF< PS*Hq zjj{cjjB뮼묷+$$쳗±V˨ ̨mLwSZk9(I{r(ʻz2kuv-ꟄjהokSXօ[;of,avZm㦲2b796 H32*:2}"nWԸ?z)QR"DID`6p}<4¨۠Ҷ}Cyt Xz%q@.o΂a = ֤24D"@&~;T&%.`X֝u*+ڝh0Ű\"8:QBdx28s. [g8eYj\ U2ms* )8ͅI덯&IJZj&H9Z[甆(6[`9@R>l9MN+-2* +F񘦬HIZH\!!q*svdrӌȀl&y/6f D:i.wkEϷSU53~^OM(|UDu=jF9ϋq HGJҒ"=(%V T,)\RXCtz5J?=R+) FMJ!58E]TԞaW*U} ^*XǚկUg Zɺմm+\UU@iMӾA{=LEJXVMl{|)+_S e9 ⥰jֺ,fٖp|4JD;–bAqkn S깯PpD&Y0' ƣ„qg%Q|8ܙPnrCRzwB+q[%v5sX% kS&Myu;dJܨ=5 !G%~ q,I))n[LGu8ơ'OdSeXLAdM *0Ϻ ZbD1<$'y`$41_\،ʖ2&H4{ ыrqأ8zrQ]ְ81ey~7d/t-I@34BP3NƓ +zα[x93҈9ZK&ۼsEq*$߸fj|ӟb!=j@78iazCvҊ\VDij%f.kͺvq*E Uxѭ>N]RNhf*#ʾT 4}Jgꁶ`lFpi ځW5ތ+⛍|qK_8Q!ҫR?!}6DpC< b?3-Hŗ_% dF'1ҏx `W#ЁC:W9M QQ=q8ouW;y?۱(:8ݯԧCI-*ˣYK&;;h,%j,Xd7UWoKaL]eq=S9B>p28nnQ&lň;4>f4wB֒[ZM;<?c.9}& HFjd9B+Ζv(Lg&kG6| q+j(c3'D1s5b'ZD%B-(vz}^ru@tvOƃs|@XEGZgGԄ%PPRHPTXIx c^O``bAql؆nxVAxL\P_sl`CWp~D{؇qBW{ȇ${#>3?v>G=I"uEqHU?"QAT^CBr1舛Uae'EB8\ys_%B]ͅHev'>vys7dzw^}Td[E'TRrը^'8Ɖ=iH]}]o v5Vtc(Wpy-[فِT )ly-8ȑ%DG(ib&p-/y 1kV8i P} @yn?)ATSՓETvVxuWKyMɔOVuUNiRP99ɕQXX3]5W*i,YFpjWcɊoySl)gn9APS7AOx)SlYZSguq, "ń#bh$%gydXgrshg@wO\Lgg] Śu'ChɒID˘]8^cbkRF*qԃ.i::諿zq"$yI_`y7[Uy.H3'0iHt9"•Cjg4䪚txx^iuhI;Ģ׬!Ww1vY{v|b~5NhC J9WsmBZǍG靊Ha9Ԉ~gE*@^J0 Xo{⭬PhB[T[ ǫṵZ5*EصrgbGjm붎/١sKš1ڷz-Zx`~{{r{+UŞw<H6Oe[:k빛{b4 ֺ{kKka{Yy;9FT:HYLu+JT` ۻ;֛ػ]K`˻|PKo5 {X`*an0U8r(G-~Y+[wJp .%v# Ț66 t!ҍ+k_r U'\t |[~ǀ,lLvOǮDĻT ;.]|Nw4eҘwO|wh:V^JrQ#'[\c,*<6`PNJla0_Þ wT<ȧ[ɉ_ȔNȁZɳ'ʟ| _dʣ|=}Z~|_²;@hy뿦˗Hs6ʻl,HUˋSKLiy9l ,ɋ[F',D,|>|V,`+{{[3y2x}=~&=T(˙}3d@4vxٴe{XS%ق*b%/zWzsG,oЇHs{mT&קgi *%v *8Ʊ4l 'Ӥ:+꣔sHP <$5r>U jmMjoydKay% (| JEM K"@Ec"hj6)o X~"H)L=՗ ڜLЛ{<1̀к]uʒ|MڷΕXZSE,) ck {Lŧ y=,8> y(_ە>h#mN1l0ˌ| ,S:y5yUL"[%VS@@S5.PaROS"DUD_V=phV_T>uJ&TUCPp U@NZ:1#KDSu=E0&Xs}{Wu2#x&@XE>KjzfZ[J޳Edvn#vy:$,tXXDl44T4kDc  %-5=EMU]emu}&.6>FNV^fnv~V;images/ssl_intro_fig1.png100644 0 0 6403 11237377775 13130 0ustar 0 0 PNG  IHDRGxksRGBgAMA a cHRMz&u0`:pQ< PLTEo` pHYs+ TIDATx͊뺲2 4~ Sߧ Jw\a= B.&,wv'6{\=UrI*i==M2$L{ !G<}7F+%U-tXBhRPm@݃/p]E)qCEg %$ѵөRETQ\P71> FX tmU*%_3 ̖=-Df9#_Ri˨6z=lٓ" 0{H_JiVQm"@S-RRi }`X ;2[(Q'mN[5د b"fvnnE6rAoMy BpCdFlgJ6_CU_1XHZVԃ‰ kr7Ɇ @цc4s9F *PnQ~M  1P"剘-1#2$beb{D9b{C0,‰Vh*Pmc4ks12X0m'"F[$nD\^؊wD wߕr`+*uZmJLܠ iW&zҬ֥܏@*UZlxSZ+-/i+SM,Jkue=<;ZL$Y.-9ѿAc}&6!ojwc cC@ن> 7PٷQm\x> 0X$b:ԍ\^1>h޷>f{DC{s >0Bԯ|0! 0"4߲oj261\|[R$P=z\PתJn}?4G%K!oHET%BrJ%%ҴMN2QJ/.*B$e64JK=R ;|,J6ølGho[[߭ՏWL{z@d<ߥᏏO<ٰh}C9X`N&0Dp4!6rDE b&m@qs bF no-"[>Q-YZf1BEd &/E `{ ȌCw(Cm7x qr3-лi>Wo12o=0cM&``@W E)P,gB -(QԛMYY*JrS J!U[R"2˅àj[LBljA-D*JkRP|Ҳ! q&Qtm#XӰC-_~P@<%B$Z],kV [],k4 z}4rH-9iu;T}M+Cw=I;`dߤ5rJ1`g=JҢTrJUàRU3ZLjtVYERg P(JgC JijlEU+YnѤuLVcjDrjBMSu}un)-=^<-=4$-=04-=l2,-})w9iY$enҗļG 0gu~"U`n"Ɔx^ǴM1@]`8`9#{O>ڪKduLfOqGE,>>]tZ1<܋:qni7guL ;y D!oyw;I4n@6WM%:Uu\B_GPg͕J :mtJ뺮?l hN+R%J+Q1N+VJu/C:i\HVPm@7>:kTR]DyDf@5W*QeY-< {QlM,ɋJ]xpX=LQu_L_>7l5|SgBM)>'Ԅ-o-c (Wm-Ta?mpYRetNlVU-WAmt,vBWJQUK= LJU&-εˁlURJ8r!pɹR) hE&7vIzU݊U"Zt/ӇPٳS|u'_=.5QZMkJP0(1Joi\J*QePZRUjQlK UeWtV&M[giuz\sJ={AԸD}%C#o>^dFK3gn<`]Ķ0o= h [3![9|`5V3 36Ė5Pa TDh->P;M,V&Āx@bfkx@C1@ϼ%2խ&1D&7Ulԃg7& !P*mtB8qRjBj#T$IiUe^ᮭ3Adҥ.UIrGtUB*UfP*? V}wjtRBD 19J-^RJRJ]nhE^ߋUJE,7UT\tHdؘhq_.D"s{ܢjwC+ǻlu\5w '=jląxZjuj%R'gN3j$-jV&z7zTz%l9Ү*UiudY[nVrnو)$ҳN5 5:jI&dI&9l~P/Oz/l?vz~={Q?_|{>Uk6/~Ͽ_z@ξDO/F{yu j>͞^fן|2{_ϯ$L2$j ^>;.UIENDB`images/ssl_intro_fig2.gif100644 0 0 5214 11237377775 13111 0ustar 0 0 GIF89a!GIF SmartSaver Ver1.1a,PI8ͻ`(dihlp,tmx|pH,Ȥrl:ШtJZجvzసE(zn|N~ϯ%SQbŮȆͺO`յذߞM^۬K\%E032ȈaD*H1#DLxLU$)Qœ2Qi䬗H)ʛXIEfB?9 Yd+8o T Ѡ jt]uIh+zjYwZz։ˎpFpAJ`.ݐTML|»5#C-R$o;zSKR^}Ld 364<7#1+Ā<7cܼO s/WM;6l+j5b|ߖ`5D`]Y}B jIVcWa_f[ BWauM @"0ymMk~9]B8ckx\q8X@,Vgbo#EM $Yh!SMoP$X郖f}4'|qz1yd3f)h)c~4f"$n$ru\r>p.ʣ0ŀ s8ttziݝ,s 0|15 |b<9gupnYL3^x3Y]$25N32@KFBbp"wm:퐊j}RH'Jx;/z>n륔}y@7пJϤtӤm5ʫ$ ޻,WU#x $'3%sT ol}_#>>e>g^ï|_Ni*Ck" g.̀kPπrg+ nN )gr Fp3sac`u Q Qh 0%7C'>1H7E*.Xb9H/|bB15h/@:x̣>Q IB/L" !$'9GR̤ YFMzl%CIR<<*WJY,Y$.wO겗 &$)bs<2)b2<3Ijc̦6ŗmz&8IɈ$'6iY}v|'<~H\VCSUaXZִ:]UP@iV(G4|G!l;lo7?B,WZ֘fzhyњv=jYպ}l=ږn֐pXw=ry:W}tZ*ѽvz8xy?Mz|Kͯ~LN<_N2'L [3{ G (NW0gL8αwc߸@HNl%;P|,*[92.X^`0hNsѥ653L+˹xs>y|mc6jh}C/9Ў1;)[F3MJ_t|Ei C6/AiTԮV1WPԛ5U4չ5gka 1ymdήEiZG{Ⱦ6iZkq{>u{~y{}?q ;\ [Ᾰƕ{ȟґ!?e񕻼)OI8Ϲws5|@q˃NtHѓt.PϣN?I:֋^9}f?Ӯ;7._v8]m4}6{ m/m+~ތ/w{wG}]헺45O.Ͽ8Xx ؀8X?;images/ssl_intro_fig2.png100644 0 0 2270 11237377775 13127 0ustar 0 0 PNG  IHDR~YsRGBgAMA a cHRMz&u0`:pQ<PLTEi- pHYs+IDATxQ0_ߏޚB%ҔASUmb 2cxP^뭚APˍ7zpm ӐﱖF[Q֣$<]0 Z>e -ﮪ+aU>0dMuA&v FF8k>kДMy[ɨ5nN3o "(|Am0m~5n)%^޺ojrV,T 8rM baJS-(emEFӑuow,Գ:㊅e}keoX%VÚ[eaMo8`gYy:.}c x kB2,2,2,2XSGdYfeYfeYfeY{dIIc:IcGuJ)Ne#)4Jf]d̽Xs:i,2,2,2,2˫?=2,2,2,2ۘ$S2,G{,rdYfeYfeYfeYfNW2,J)urd.IENDB`images/ssl_intro_fig3.gif100644 0 0 7664 11237377775 13125 0ustar 0 0 GIF89aC̙fff!GIF SmartSaver Ver1.1a,CI8ͻ`(dihlp,tmx|pH,Ȥrl:ШtJZجvzx5zn|NxDB&l Ùr["Nе8l2aӰbu.jڋro.p\ްoRyW\pD wY󰿮Fܱ/L)怯ɥؼ3qn,0ss64+ IeZ3 )WP,!+pH%ωXCEXbX\i./ Ad.a`kƥq#HmuqvLx8-4P3F-fScH,ЃE)$m؎'r'AuytAK=1pg fCI$$]cH j!d+=PeF>`/FI2#!sTqt9#GN=(;I^Α[#M2 !-]IcN$8 7RҘlif&bvP"Ja YC3]<(q0 1yӋ.HFDɏ9A7rk>Jړ8LqNbc֫ÄmؾCr]Lg)9R1eexy^1h&+?Ʈ'39l׼g:0"[x=yφ>=9ǂˣeҕ3i`ӛt(R;XĘy,izƢMDzwjoGh&󼤜sOl سu`*!Yu;i0N7kJԛAidݢf6Wԝj櫋mdx6]o`׋z I޴jr0h;_fGP{{˵|sMqyere<0坣<(+C':ܥhN/+ԣ*QVRs(L^ϩX^ 훿_:hIGoZ.LϿDS}{5'v&7vKU3CfxSq3'h(AȈiusQE!Q<7hHf\UvkGOWdaP%}~;Gp MEsy%ЎtXA4WAȊlց5MFwe"9O**h,֨/-w0;$^Qq8BY$vfrajC҇1fIxBYӔs? Ty{XN;>ȕ]镉r`b9fGJiɖ@qRrIyuI&tyk—n(,~I~I{),iYm;axYYb.?hO&2&:(Z Z*5tpu(h<:BZDzFzQ;jMCc<4zVz7ʤ+= enD} (6fZ'2ƥq2J\$OrhZej8`> A҆3PJjI:z:dl wKZHWgzr60G$e`ʪԥʌ'QSl5Ko)|΂MtZfka w;.|?@<=A¾@ĿC7JKL1O-P2QS2IVWؑҞZ۟\([]] `a7cdefghibklmnopqrstuvwxyz{|}~3D;images/ssl_intro_fig3.png100644 0 0 5010 11237377775 13123 0ustar 0 0 PNG  IHDRCl?sRGBgAMA a cHRMz&u0`:pQ<PLTE̙fffQ< pHYs+ PIDATxKr8 ž qTS57fAMKɀjulYq Q@iӦM6m?1Nor<9)TPkqPy1a;J(cm p/;w`3P,+ C!77PChQyuX笳puϩX`aaB~X{YgYqk@JPrXqo%  pIPL@1(egQMEX235XPMt^R,JX9*(`/(jd+`RcI=6E 6E6H~6e~D{?[!Q?ks)oaoj8}^ԱEr P P P P P P 5,*į. S[A|3 ns*ҡڴ&UjQ<PTR/~>qA^PHH~'#R(+B)Be Bkw.XDS%T* GJOPe (sJU$rTQ>V;)5N+&1OKd9lJkA6Ioio!obZȜndFlST?~.MefSG۵Px|u{MuXR~hSB]ze-ٔ6_B,j|W@[fDRl~m*T_~"%5 CU+&!]u (.!~61yH6E &1v-/N 6}2/ީ~Nbxwktӱ_PnwkP>?;K%u2ԭ:6mڴiӶS[IENDB`images/up.gif100644 0 0 71 11237377775 10546 0ustar 0 0 GIF89a @Xq!,  4{n;index.html100644 0 0 14663 11237400230 10224 0ustar 0 0 Apache HTTP サーバ バージョン 2.2 ドキュメント - Apache HTTP サーバ
<-
install.html100644 0 0 61054 11237400230 10557 0ustar 0 0 コンパイルとインストール - Apache HTTP サーバ
<-

コンパイルとインストール

This translation may be out of date. Check the English version for recent changes.

この文書で扱う範囲は、Unix や Unix に類似したシステムでの Apache HTTPd サーバのコンパイルとインストールです。 Windows における コンパイルとインストールに関しては「Microsoft Windows で Apache HTTPd を使う」をご覧下さい。 その他のプラットホームに関しては「プラットホーム」をご覧下さい。

Apache HTTPd では他の Open Source プロジェクトと同様、 ビルド環境構築に libtoolautoconf を使うようになっています。

マイナーバージョンからその次のバージョンにアップグレードする (2.2.50 から 2.2.51 へ等) 場合は、まず アップグレードをご覧下さい。

top

概要 (せっかちな人向け)

ダウンロード $ lynx http://httpd.apache.org/download.cgi
展開 $ gzip -d httpd-NN.tar.gz
$ tar xvf httpd-NN.tar
$ cd httpd-NN
設定 $ ./configure --prefix=PREFIX
コンパイル $ make
インストール $ make install
カスタマイズ $ vi PREFIX/conf/httpd.conf
テスト $ PREFIX/bin/apachectl -k start

NN は最新のバージョンナンバーに、 PREFIX はインストールするサーバでのファイルシステムのパスに、 置き換えてください。PREFIX を指定しなかった場合は、 デフォルトの /usr/local/apache2 になります。

Apache HTTP サーバのコンパイルとインストールに必要なものをはじめとして、 コンパイルとインストールについては、次に詳しく記述されています。

top

必要なもの

Apache HTTPd のビルドには次のものが必要です:

ディスクスペース
ディスクに少なくとも 50 MB の一時的な空き容量があるように 気を付けてください。インストール後は Apache は 10 MB 程度の ディスクスペースを占めます。実際に必要になるディスクスペースは、 設定オプションやサードパーティー製モジュールをどう選択するかによって 大きく変わるでしょう。
ANSI-C コンパイラとビルドシステム
ANSI-C コンパイラをインストールしておいて下さい。お薦めは Free Software Foundation (FSF) による GNU C compiler (GCC) です。GCC がない場合は、 少なくとも提供されているコンパイラが ANSI 準拠であることを確認しておいて下さい。 それから、変数 PATH には make といった基本的なビルドツールが含まれている必要があります。
時刻を正確にする
HTTP プロトコルの要素は日時の時刻で表現されています。ですから、 正確な時刻にシンクロさせる機能をシステムに設定することを吟味してみて下さい。 Network Time Protocol (NTP) をベースとした ntpdate や xntpd プログラムが この目的によく用いられます。NTP ソフトウェアや公開 NTP サーバに関する詳細は、NTP ホームページ をご覧下さい。
Perl 5 [オプション]
提供されているスクリプト幾つか、例えば apxsdbmmanage は Perl で書かれているので、Perl 5 インタプリタが必要になります (5.003 以降)。 Perl インタプリタを複数インストールしている (たとえば全体のシステムの一部 としてインストールされている Perl 4 と、自分で追加でインストールした Perl 5 があるなどの) 場合、--with-perl オプション (下記参照) を使って configure が意図したものを使うように 明示的に指定すると良いでしょう。 configure スクリプトで Perl 5 インタプリタが 見つからない場合は、この影響を受けるサポートスクリプトが使えなくなります。 もちろん、Apache HTTPd のコンパイルとインストールは問題なく行えます。
apr/apr-util >= 1.2
aprapr-util は Apache HTTPd ソースリリースに同梱されていますし、どんな環境でもほぼ問題なく 使えるはずです。ただし aprapr-util のバージョン 1.0 や 1.1 がシステムの一部として既にインストールされている場合、 apr/apr-util を 1.2 にアップグレードするか、 httpd を隔離した環境でビルドする必要があります。 バンドルされている apr/apr-util を使って アップグレードする場合は、これらを手動でインストールする必要があります :

# Build and install apr 1.2
cd srclib/apr
./configure --prefix=/usr/local/apr-httpd/
make
make install

# Build and install apr-util 1.2
cd ../apr-util
./configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/
make
make install

# Configure httpd
cd ../../
./configure --with-apr=/usr/local/apr-httpd/ --with-apr-util=/usr/local/apr-util-httpd/

top

ダウンロード

Apache HTTP サーバは Apache HTTP サーバダウンロードサイトからダウンロードできますし、 同じ場所に幾つかのミラーサイトもリストしています。 UNIX に類似するシステムで Apache HTTPd を使うユーザは、ソースを ダウンロードしてビルドしたほうが良いでしょう。 ビルドの手順(下記)は簡単ですし、そのおかげでニーズに 見合ったカスタマイズを簡単にできます。 さらに、バイナリのリリースはソースリリースよりも 遅れていることがよくあります。 それでもバイナリをダウンロードしたのであれば、 ディストリビューションの中にある INSSTALL.bindist ファイルの説明に従ってください。

ダウンロード後、ダウンロードしたものが Apache HTTP サーバの完全で改竄されていないバージョンであることを 検証することが重要です。これはダウンロードした tarball の PGP 署名を テストすることによって検証します。 この手順の詳細は ダウンロード ページ にあり、さらに詳しい例は PGP の使用 に記載されています。

top

展開

Apache HTTPd の tarball からソースファイルを展開して取り出すとは、 単なる圧縮の解除と tar の展開です:

$ gzip -d httpd-NN.tar.gz
$ tar xvf httpd-NN.tar

配布用のソースコードがある現在いるディレクトリの下に、 新しいディレクトリが作られます。 サーバをコンパイルする段階に進む前に、そのディレクトリに cd で移動してください。

top

ソースツリーを設定する

次のステップは、あなたのプラットホームと 個人的な要求に合うように Apache HTTPd ソースツリーを設定することです。 これは配布ディレクトリのルートディレクトリにある、 configure スクリプトで行ないます。 (Apache HTTPd ソースツリーの未リリース 版をダウンロードした開発者は、次のステップに進む前に autoconflibtool をインストールして buildconf を実行する必要があります。 公式リリースではこの作業は必要ありません。)

デフォルトオプションを使ってソースツリーを全て設定する のであれば、単純に ./configure とタイプしてください。 デフォルトオプションを変更できるように、configure には様々な変数やコマンドラインオプションが用意されています。

最も重要なオプションは、Apache HTTPd がこの後でインストールされる位置 --prefix です。Apache HTTPd は、このインストール位置に おいて正常に動作するように設定しなければならないからです。 さらに詳細なファイル位置の制御は追加の 設定オプション でできます。

この時点で、モジュール を有効にしたり 無効にしたりすることで Apache HTTPd 本体に含まれる 機能 を指定できます。Apache HTTPd 本体にはデフォルトで、モジュールの Base セットが 含まれます。その他のモジュールは --enable-module オプションで 有効になります。ここで module はモジュールの名前で、 つまりそれはモジュールの名前から mod_ 文字列を取り除いた後に アンダースコアをダッシュで置換した文字列です。 これとは別の方法で --enable-module=shared オプションを使って、モジュールを シェアードオブジェクト (DSO) -- 実行時にロードしたり アンロードしたりできる形式 -- としてコンパイルすることもできます。 同様に、--disable-module オプションで Base モジュールを無効化することもできます。 これらのオプションを使っているときに、もし指定したモジュールが存在しなくても configure は警告を上げることなく、単純にオプションを 無視することに気をつけてください。

上記に加えて、configure スクリプトに、 コンパイラ、ライブラリ、ヘッダファイルの位置を追加情報として渡す 必要がある場合があります。このような場合には、環境変数あるいは コマンドラインオプションで configure に渡します。 詳細に関しては configure マニュアルページ をご覧ください。

ちょっとどんなことができるかを見せましょう。 ここで典型的な例として、/sw/pkg/apache というインストールツリーでコンパイラとフラグを指定して、 さらに二つの追加モジュール mod_rewritemod_speling を後で DSO メカニズムでロードするようにコンパイルしてみます:

$ CC="pgcc" CFLAGS="-O2" \
./configure --prefix=/sw/pkg/apache \
--enable-rewrite=shared \
--enable-speling=shared

configure を実行したら、システムの機能を テストしたり、後でサーバをコンパイルするために必要な Makefile を生成したりするのに数分間かかるでしょう。

個々の configure オプションの詳細に関しては configure マニュアルページ をご覧ください。

top

ビルド

これで Apache HTTPd の様々なパーツをビルドすることができます。 次のコマンドを単純に実行するだけです:

$ make

基本的な設定をするのに数分かかりますが、 あらかじめご了承ください。 また、時間はハードウェアや有効にしたモジュールの数に 大きく依存するでしょう。

top

インストール

さて、設定したインストール PREFIX (前述の --prefix オプションを参照) 以下にパッケージをインストールする段階になりました。 次のコマンドを実行してください:

$ make install

アップグレードする場合は、インストールでは設定ファイルや ドキュメントファイルの上書きは行いません。

top

カスタマイズ

次に PREFIX/conf/ 以下にある 設定ファイルを編集して、 Apache HTTP サーバをカスタマイズします。

$ vi PREFIX/conf/httpd.conf

docs/manual/ の Apache HTTP サーバマニュアルをざっと見てください。 または、http://httpd.apache.org/docs/2.2/ にあるマニュアル最新版、設定ディレクティブに当たってみてください。

top

テスト

次のコマンドを実行して Apache HTTP サーバを開始できます:

$ PREFIX/bin/apachectl -k start

URL http://localhost/ を通して最初のドキュメントに対する リクエストを発行する事ができるはずです。これで見える ウェブページは DocumentRoot 以下に置かれたもので、通常は PREFIX/htdocs/ でしょう。 サーバを再び停止するには、 次のコマンドを実行します:

$ PREFIX/bin/apachectl -k stop

top

アップグレード

アップグレードでまず行なうべきことは、リリースアナウンスと ソースディストリビューションに入っている CHANGES を読んで、 自身のサイトに対して影響を及ぼす変更点を探すことです。 メジャーリリース間の変更をする場合 (例えば 1.3 から 2.0 へ、2.0 から 2.2 へ) は、コンパイル時や実行時の設定に大きな差異があるでしょうから、 手動の調整が必要になるでしょう。モジュールも全て、API の変更に合わせるためにアップグレードが必要になるでしょう。

マイナーバージョンから次のバージョンにアップグレードする場合 (例えば 2.2.55 から 2.2.57 へ) は、もっと簡単です。 make install を実行しても今あるドキュメント、 ログファイル、設定ファイルは上書きされません。 さらに、マイナーバージョン間では configure オプション、 実行時の設定、モジュール API に不整合が起こらないように、 開発者は最大限の努力をしています。 大抵の場合、同一の configure コマンドライン、 同一の設定ファイル、モジュール全てが正常に動作するはずです。

マイナーバージョンでアップグレードする場合は、 既にインストールされているサーバの build ディレクトリ内か、 以前インストールに使ったソースコードツリーの最上位ディレクトリ内にある、 config.nice ファイルを探してください。 このファイルにはソースツリーを設定した時に使った configure コマンドラインが、そのまま入っています。 次のバージョンにアップグレードする場合は config.nice ファイルを新しいバージョンのソースツリーにコピーし、 必要であればそれを編集した後に、次のように実行します。

$ ./config.nice
$ make
$ make install
$ PREFIX/bin/apachectl -k graceful-stop
$ PREFIX/bin/apachectl -k start

新しいバージョンを使用する場合は、 実際に運用を始める前に、必ず自分用の環境でテストすべきです。 最終的にアップグレードする前に、非互換性がないかをテストするために、 例えば、異なる --prefix と異なるポート (Listen ディレクティブで設定します) を使用することで、古いバージョンに影響を与えずに新しいバージョンを インストールし、実行できます。
invoking.html100644 0 0 25127 11237400230 10736 0ustar 0 0 Apache の起動 - Apache HTTP サーバ
<-

Apache の起動

This translation may be out of date. Check the English version for recent changes.

Windows 上では、Apache は通常は Windows NT, 2000, XP ではサービスとして、Windows 9x, ME ではコンソールアプリケーションとして実行されます。 詳細に関しては、「 サービスとして実行する」と「 コンソールアプリケーションとして実行する」をご覧下さい。

Unixでは、httpd プログラムが、バックグラウンドで常にリクエスト処理を行う デーモンとして実行されます。この文書ではどのように httpd を起動するかについて記述しています。

top

Apache の起動方法

もし、設定ファイル中で指定されている Listen がデフォルトの 80 (もしくは 1024 以下の他のポート) である場合は、Apache を起動するためには root 権限が必要になりますが、 これはこの特権ポートにバインドするためです。 起動して、一度ログファイルを開くといった準備のための 動作を幾つか実行した後は、クライアントからのリクエストに対する listen と応答を実際に行うプロセスを起動します。 メインの httpd プロセスは root 権限で走り続けますが、 子プロセスはもっと低い権限で走ります。 これは選択したマルチプロセッシングモジュールで制御されます。

推奨の httpd 実行プログラムの起動方法は、 apachectl 制御スクリプトを使用する方法です。このスクリプトは、httpd がオペレーティングシステム上で正常に動作するように必要な環境変数を 適切に設定して、httpd バイナリを起動します。 apachectl はどんなコマンドライン引数も通過させますので、 httpd のどのコマンドラインオプションも apchectl のオプションとして使用できます。 また、apchectl スクリプトを直接編集し、 スクリプト先頭付近の HTTPD 変数を変更することで、 httpd バイナリの正しい位置を指定したり、常に 付加させるコマンドライン引数を指定したりすることができます。

httpd が起動されてまず最初にすることは、 設定ファイル httpd.conf の位置を特定して読み込むことです。 このファイルの位置はコンパイル時に設定されますが、実行時に -f コマンドラインオプションを使って 位置を指定することもできます。例えば次のようにです。

/usr/local/apache2/bin/apachectl -f /usr/local/apache2/conf/httpd.conf

スタートアップが万事上手くいったら、サーバはターミナルから 切り離されて、コマンドプロンプトが即座に戻ってくるでしょう。 これはサーバが起動している状態を示しています。 その後はブラウザでサーバに接続して、 DocumentRoot ディレクトリのテストページやそこからリンクされている ローカルのドキュメントを見ることができるでしょう。

top

起動時のエラー

Apache は、起動時に致命的な問題に遭遇すると、 終了する前に、コンソールか ErrorLog のどちらかに問題を記述したメッセージを出力します。 最もよくあるエラーメッセージは 「Unable to bind to Port ...」 です。このメッセージは普通は次のどちらかが原因です。

  • root でログインしていない時に、 特権ポートでサーバを起動しようとした。
  • 同じポートに既にバインドされている Apache がもう一つあるときや他のウェブサーバが存在している時に、 サーバを開始しようとした。

より多くの問題解決の方策の説明は、 Apache FAQ をご覧下さい。

top

ブート時の起動

システムがリブートした後でも サーバが実行され続けるようにしたい場合は、 apachectl を呼び出すものをシステムスタートアップファイル (通常 rc.localrc.N 内のファイル) に追加しなければなりません。 この方法では Apache を root 権限で起動します。 これをする前に、セキュリティやアクセス制限が 適切に設定されていることを確認してください。

apachectl スクリプトは通常は、標準的な SysV init スクリプトとして動作するように設計されています。 start, restart, stop といった引数をとって、httpd への適切なシグナルに変換します。 ですから、通常は単に適切な init ディレクトリ内から apachectl へリンクすることができます。しかし、 念のためシステムの要求に合致していることを確認してください。

top

追加情報

httpdapachectl、サーバに含まれていたその他補助プログラムの、 コマンドラインオプションに関する追加情報は、 サーバと補助プログラムページに 記載されています。 Apache 配布に含まれている全モジュール、 それによって提供されるディレクティブ のドキュメントもあります。

license.html100644 0 0 32120 11237400230 10523 0ustar 0 0 The Apache License, Version 2.0 - Apache HTTP Server
<-

The Apache License, Version 2.0

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

  1. Definitions

    "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.

    "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.

    "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.

    "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.

    "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.

    "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.

    "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).

    "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.

    "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."

    "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.

  2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
  3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
  4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
    1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
    2. You must cause any modified files to carry prominent notices stating that You changed the files; and
    3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
    4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.

    You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.

  5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
  6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
  7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
  8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
  9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

Licensed 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.
logs.html100644 0 0 111402 11237400230 10066 0ustar 0 0 ログファイル - Apache HTTP サーバ
<-

ログファイル

This translation may be out of date. Check the English version for recent changes.

ウェブサーバを効果的に管理するためには、サーバの活動やパフォーマンス、 今発生しているかもしれない問題に関するフィードバックを得ることが必要です。 Apache HTTP サーバには非常に包括的で柔軟なロギング機能があります。 この文書はロギング機能の設定の仕方と、ログに何が書かれているかを 理解するための方法を説明します。

top

セキュリティに関する警告

Apache がログファイルを書いているディレクトリに書き込める人は、 ほぼ確実にサーバが起動された uid へのアクセスを手に入れることができます。 そして、それは通常は root ユーザです。 ちゃんと結果を考えることなく、そのディレクトリへの 書き込み権限を与えないでください。詳しくは セキュリティのこつの文書を 読んでください。

加えて、ログファイルにはクライアントからの情報がそのまま、 エスケープされることなく書かれています。ですから、悪意のある クライアントがログファイルに制御文字を挿入することができます。 生のログを扱うときは注意してください。

top

エラーログ

ErrorLog ディレクティブにより 名前と場所が決まるサーバのエラーログは、一番重要なログファイルです。 Apache の診断情報はここに送られ、リクエストを処理しているときに 発生したエラーはすべてここに記録されます。サーバを起動したときや、 サーバの動作に問題が起こったときは、一番最初に調べるべき ところです。間違いの詳細や修正方法がそこに書かれていることが よくあります。

エラーログは普通はファイルに書かれます (通常 unix システムでは error_log、Windows と OS/2 では error.log)。 Unix システムではエラーを syslogパイプでプログラムに送る ことができます。

エラーログの書式は比較的自由度の高いもので、説明的に書かれています。 ただし、いくつかの情報はほとんどのエラーログのエントリにあります。 例えば、代表的なものに次のようなメッセージがあります。

[Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1] client denied by server configuration: /export/home/live/ap/htdocs/test

ログエントリの最初の項目はメッセージの日付と時刻です。 二つめの項目は報告されているエラーの重要度です。 LogLevel で重要度のレベルを 制限することによりエラーログに送られるエラーの種類を制御することが できます。三つ目の項目はエラーを発生させたクライアントの IP アドレス です。残りはメッセージで、この場合はサーバがクライアントのアクセスを 拒否するように設定されている、ということを示しています。 サーバはリクエストされた文書の (ウェブのパスではなく) ファイルシステムの パスを報告します。

非常に広範囲のメッセージがエラーログに現れます。たいていのものは 上の例のような感じです。エラーログには CGI スクリプトのデバッグ 出力も書かれます。CGI スクリプトが stderr に書いた すべての情報は直接エラーログにコピーされます。

情報を追加したり削除したりしてエラーログをカスタマイズすることは できません。しかし、リクエストに対するエラーログのエントリは、 対応するエントリがアクセスログにあります。 例えば、上の例のエントリはアクセスログのステータスコード 403 の エントリに対応します。アクセスログはカスタマイズ可能ですので、 そちらを使うことによりエラーの状況に関する情報をより多く 手に入れることができます。

テストの最中は、問題が発生しているかどうかを見るために、 常にエラーログを監視するのが役に立つ場合がよくあります。 Unix システムでは、次のものを使うことができます。

tail -f error_log

top

アクセスログ

サーバアクセスログはサーバが処理をしたすべてのリクエストを 記録します。アクセスログの場所と内容は CustomLog ディレクティブにより決まります。ログの内容の選択を簡潔にするために LogFormat ディレクティブを使用することができます。このセクションはアクセスログに 情報を記録するためのサーバの設定方法を説明します。

もちろん、アクセスログに情報を蓄積することはログ管理の 始まりに過ぎません。次の段階は有用な統計を取るためにこの情報を 解析することです。一般的なログ解析はこの文書の範囲外で、 ウェブサーバ自身の仕事というわけでもありません。この話や、 ログ解析を行なうアプリケーションの情報を得るには、 Open Directory Yahoo を調べてください。

いろんなバージョンの Apache httpd が mod_log_config, mod_log_agent, TransferLog ディレクティブといった、 他のモジュールやディレクティブを使ってアクセスのロギングを 制御してきました。今では、CustomLog がすべての古い ディレクティブの機能を含むようになっています。

アクセスログの書式は非常に柔軟な設定が可能です。 書式は C の printf(1) フォーマット文字列に非常に似た フォーマット文字列 により指定されます。いくつか次の節で例を示します。 フォーマット文字列に使用できる内容の一覧は mod_log_config の文書 を見てください。

Common Log Format

アクセスログのよくある設定に以下のものがあります。

LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog logs/access_log common

これは、ニックネーム common を定義し、 ログのフォーマット文字列の一つと関連付けます。フォーマット文字列は パーセントディレクティブからなり、それぞれのパーセントディレクティブは サーバにどの情報をロギングするかを指示します。フォーマット文字列に 文字をそのまま入れることもでき、それらはログの出力に直接コピーされます。 そこに引用文字 (") を書くときは、 フォーマット文字列の最後として解釈 されることを防ぐためにバックスラッシュでエスケープする必要があります。 フォーマット文字列には改行用の "\n"、タブ用の "\t" という特別な制御文字も含めることができます。

CustomLog ディレクティブは 既に定義された ニックネーム を使って新しいログファイルを設定します。 アクセスログのファイル名はスラッシュで始まらない限り、 ServerRoot からの相対パスとして 扱われます。

上の設定は Common Log Format (CLF) と呼ばれる形式で ログエントリを書きます。この標準の形式は異なるウェブサーバの多くが 生成することができ、多くのログ解析プログラムが読みこむことができます。 CLF により生成されたログファイルのエントリは以下のようになります:

127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326

このログエントリのそれぞれの部分の意味は以下で説明します。

127.0.0.1 (%h)
これはサーバへリクエストをしたクライアント (リモートホスト) の IP アドレスです。HostnameLookupsOn の場合は、サーバはホスト名を調べて、 IP アドレスが書かれているところに記録します。しかし、この設定は サーバをかなり遅くするので、あまりお勧めできません。 そうではなく、logresolve の ようなログの後処理を行なうプログラムでホスト名を調べるのが良いでしょう。 ここに報告される IP アドレスは必ずしもユーザが使っているマシンの ものであるとは限りません。ユーザとサーバの間にプロキシサーバが あれば、このアドレスは元のマシンのものではなく、プロキシの アドレスになります。
- (%l)
出力中の「ハイフン」は要求された情報が手に入らなかったということを 意味します。この場合、取得できなかった情報はクライアントのマシンの identd により決まる RFC 1413 のクライアントの アイデンティティです。この情報はあまり信用することができず、 しっかりと管理された内部ネットワークを除いては使うべきではありません。 Apache は IdentityCheckOn になっていない限り、この情報を得ようとすらしません。
frank (%u)
これは HTTP 認証による、ドキュメントをリクエストした人の ユーザ ID です。CGI スクリプトには通常同じ値が REMOTE_USER 環境変数として与えられます。リクエストのステータスコード (以下を参照) が 401 であった場合は、ユーザは認証に失敗しているので、 この値は信用できません。ドキュメントがパスワードで保護されていない 場合は、このエントリは前のものと同じように "-" に なります。
[10/Oct/2000:13:55:36 -0700] (%t)
サーバがリクエストを受け取った時刻です。書式は:

[day/month/year:hour:minute:second zone]
day = 2*digit
month = 3*letter
year = 4*digit
hour = 2*digit
minute = 2*digit
second = 2*digit
zone = (`+' | `-') 4*digit

ログのフォーマット文字列に %{format}t を 指定することで、別の形式で時刻を表示させることもできます。 このとき、format は C の標準ライブラリの strftime(3) の形式になります。
"GET /apache_pb.gif HTTP/1.0" (\"%r\")
クライアントからのリクエストが二重引用符の中に示されています。 リクエストには多くの有用な情報があります。まず、この場合クライアントが 使ったメソッドは GET です。次に、クライアントは リソース /apache_pb.gif を要求しました。そして、 クライアントはプロトコル HTTP/1.0 を使用しました。 リクエストの各部分を独立にログ収集することもできます。例えば、 フォーマット文字列 "%m %U%q %H" は メソッド、パス、クエリ文字列、プロトコルをログ収集し、 結局 "%r" とまったく同じ出力になります。
200 (%>s)
サーバがクライアントに送り返すステータスコードです。 この情報は、リクエストが成功応答 (2 で始まるコード) であったか、 リダイレクション (3 で始まるコード) であったか、クライアントによる エラー (4 で始まるコード) であったか、サーバのエラー (5 で始まるコード) であったか、を表すので、非常に大切です。ステータスコードの 完全なリストは HTTP 規格 (RFC2616 第 10 節) にあります。
2326 (%b)
この最後のエントリはクライアントに送信されたオブジェクトの、 応答ヘッダを除いたサイズを表します。コンテントがクライアントに送られなかった 場合は、この値は "-" になります。コンテントが無い場合に "0" をログ収集するには、%b ではなく %B を使ってください。

Combined Log Format

もう一つのよく使われる書式は Combined Log Format と呼ばれています。 以下のようにして使うことができます。

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog log/access_log combined

この書式の最初の方は Common Log Format とまったく同じで、最後に 二つ追加のエントリがあります。追加のエントリはパーセントディレクティブ %{header}i を使っています。ここで header は HTTP のリクエストヘッダのどれかです。この書式による アクセスログは以下のような感じになります:

127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"

追加のエントリは:

"http://www.example.com/start.html" (\"%{Referer}i\")
"Referer" (意図的な綴り間違い) HTTP リクエストヘッダです。 これはクライアントが報告してくる参照元のサイトを表します。 (この場合は、/apache_pb.gif にリンクしているか、 それを含んでいるページです)。
"Mozilla/4.08 [en] (Win98; I ;Nav)" (\"%{User-agent}i\")
User-Agent HTTP リクエストヘッダです。これはクライアントのブラウザが 自分自身のことを報告してくる情報です。

複数のアクセスログ

複数のアクセスログは単に設定ファイルに複数の CustomLog ディレクティブを書くことで作成されます。例えば、以下のディレクティブは 三つのアクセスログを作ります。最初のものは基本的な CLF の情報で、 二つ目と三つ目は referer とブラウザの情報です。最後二つの CustomLogReferLog ディレクティブと AgentLog ディレクティブの効果をまねる方法を示しています。

LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog logs/access_log common
CustomLog logs/referer_log "%{Referer}i -> %U"
CustomLog logs/agent_log "%{User-agent}i"

この例は LogFormat で ニックネームを定義する必要がない、 ということも示しています。ニックネームの代わりに、 CustomLog ディレクティブに 直接ログの書式を指定することができます。

条件付きログ

クライアントのリクエストの特徴に基づいてアクセスログにエントリの 一部をロギングしない方が便利なことがあります。これは 環境変数 の補助により簡単に実現できます。まず、 リクエストが何らかの条件に合うということを表すために環境変数が 設定される必要があります。これは通常は SetEnvIf により 行なわれます。そして、CustomLog ディレクティブの env= 節を使って環境変数が設定されているリクエストを 含めたり排除したりすることができます。いくつか例を挙げます:

# Mark requests from the loop-back interface
SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog
# Mark requests for the robots.txt file
SetEnvIf Request_URI "^/robots\.txt$" dontlog
# Log what remains
CustomLog logs/access_log common env=!dontlog

他の例として、英語を話す人からのリクエストとそれ以外の人からのリクエストを 分けたい、という場合を考えてみてください。

SetEnvIf Accept-Language "en" english
CustomLog logs/english_log common env=english
CustomLog logs/non_english_log common env=!english

ここまででは条件付きロギングが非常に強力で柔軟であることを示してきましたが、 それがログの内容を制御する唯一の方法というわけではありません。ログファイルは サーバの活動の完全な記録である方がより役に立ちます。単純にログファイルを 後処理して、考慮したくないログを削除する方が簡単であることがよくあります。

top

ログの交替

普通の負荷のサーバでさえ、ログファイルに保存される情報の量は 膨大になります。アクセスログのファイルは普通 10,000 リクエスト毎に 1 MB 以上増えます。ですから、既存のログを移動したり、削除したりして、 定期的にログを交替させることが必要になります。これはサーバの実行中には 行なえません。というのは、Apache はファイルが open されている間は ずっと古いログファイルに書き続けるからです。 新しいログファイルを open できるように、ログファイルが移動されたり 削除された後に、サーバを再起動する 必要があります。

優雅な 再起動を行なうことで、サーバは既存のコネクションや 処理待ちのコネクションを失うことなく新しいログファイルを open させる ことができます。しかし、これを実現するために、サーバは古いリクエストを 扱っている間は古いログファイルに書き続ける必要があります。 ですから、再起動の後ではログファイルの処理を始める前に、しばらく待たなければ なりません。単にログを交替させて、ディスクの節約のために古いログを 圧縮する普通のシナリオは:

mv access_log access_log.old
mv error_log error_log.old
apachectl graceful
sleep 600
gzip access_log.old error_log.old

ログの交替をするもう一つの方法はパイプ経由のログを使うもので、次の節で説明されています。

top

パイプ経由のログ

Apache httpd はエラーログとアクセスログをファイルに直接書く代わりに、 パイプを通して別のプログラムに書き出すことができます。 この機能により、主サーバにコードを追加することなく ロギングの柔軟性が非常に高まっています。パイプにログを書くためには、 単にファイル名をパイプ文字 "|" に置き換え、その続きに 標準入力からログのエントリを受けとる実行プログラムの名前を書くだけです。 Apache はパイプ経由のログ用のプロセスをサーバの起動時に実行し、 サーバの実行中にそのプログラムがクラッシュしたときはそれを再び 実行します。(この最後の機能がこの技術が「信頼性のあるパイプ経由のロギング」 と呼ばれている理由です。)

パイプ経由のログ用のプロセスは Apache httpd の親プロセスから起動され、 そのプロセスのユーザ ID を継承します。これは、パイプ経由のログ用の プログラムは普通 root として実行されることを意味します。 ですから、プログラムを簡単で安全に保つことが非常に重要です。

パイプ経由のログの重要な利用法は、サーバの再起動なしでログの交替を することです。Apache HTTP サーバにはこのための rotatelogs と呼ばれる簡単な プログラムが付属しています。たとえば、24 時間毎にログを交替させるには、 以下のものを使うことができます:

CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/access_log 86400" common

パイプの先で呼ばれるコマンド全体が引用符で囲まれていることに注目して ください。この例はアクセスログを使っていますが、エラーログにも同じ技術を 使うことができます。

似ているけれど、よりずっと柔軟な cronolog というログ交替用の プログラムが外部のサイトにあります。

条件付きロギングと同様、パイプ経由のログは非常に強力な 道具ですが、オフラインの後処理のような、より簡単な解決方法があるときは 使わない方が良いでしょう。

top

バーチャルホスト

多くの バーチャルホスト のあるサーバを実行している ときは、ログファイルの扱い方にいくつかの方法があります。 まず、単独のホストのみのサーバとまったく同じようにログを使うことができます。 ロギングディレクティブを主サーバのコンテキストの <VirtualHost> セクションの外に置くことで、 すべてのログを同じアクセスログとエラーログにログ収集することができます。 この手法では個々のバーチャルホストの統計を簡単にとることはできません。

CustomLogErrorLog ディレクティブが <VirtualHost> の中に 置かれた場合は、そのバーチャル ホストへのすべてのリクエストやエラーがそこで指定されたファイルにのみ ログ収集されます。ロギングディレクティブのないバーチャルホストは 依然としてリクエストが主サーバのログに送られます。この手法は少ない バーチャルホストに対しては非常に有用ですが、ホストの数が非常に多くなると 管理が大変になります。さらに、ファイル記述子の限界の問題を起こすことが あります。

アクセスログには、非常に良い妥協案があります。バーチャルホストの 情報をログのフォーマット文字列に加えることで、すべてのホストへの リクエストを同じログにログ収集して、後でログを個々のファイルに分割することが できます。たとえば、以下のディレクティブを見てください。

LogFormat "%v %l %u %t \"%r\" %>s %b" comonvhost
CustomLog logs/access_log comonvhost

%v がリクエストを扱っているバーチャルホストの名前を ログ収集するために使われています。そして、split-logfile のようなプログラムを 使ってアクセスログを後処理することで、 バーチャルホスト毎のファイルにログを分割することができます。

残念ながら、エラーログには同様の手法はありません。ですから、 すべてのバーチャルホストを同じエラーログの中に混ぜるか、 バーチャルホスト毎にエラーログを使うかを選ばなければなりません。

top

他のログファイル

実際に送受信したバイト数のログ

mod_logio は、 ネットワーク上で実際に送受信した数をログする 二つのフィールド (%I と %O) を LogFormat ディレクティブに追加します。

Forensic ログ

mod_log_forensic はクライアントリクエストの forensic ログを取ります。ログはリクエスト処理前と処理後に 行われますので、1 リクエストに対して 2 行のログが出力されます。 forensic ロガーはとても厳密でカスタマイズできません。 デバッグやセキュリティ用のツールとして有効かもしれません。

PID ファイル

起動時に、Apache は親 httpd プロセスのプロセス ID を logs/httpd.pid に保存します。この ファイル名は PidFile ディレクティブを使って 変更することができます。プロセス ID は管理者が親プロセスに シグナルを送ることでデーモンを再起動したり終了させたりするときに 使用します。Windows では、代わりに -k コマンドオプションを 使ってください。詳しい情報は 終了と 再起動 のページを見てください。

スクリプトログ

デバッグの補助のために、ScriptLog ディレクティブは CGI スクリプトの入力と出力を記録するようにできます。 これはテスト用にのみ使用して、通常のサーバでは使用しないでください。 詳しい情報は mod_cgi の文書 にあります。

リライトログ

mod_rewrite の強力で 複雑な機能を 使っているときは、ほぼいつもデバッグを簡単にするために RewriteLog の使用が 必要でしょう。このログファイルにはリライトエンジンがリクエストを 書き換える方法の詳細な解析が出力されます。詳しさの度合は RewriteLogLevel で制御できます。

misc/index.html100644 0 0 7260 11237400230 11132 0ustar 0 0 Apache Miscellaneous Documentation - Apache HTTP Server
<-

Apache Miscellaneous Documentation

Below is a list of additional documentation pages that apply to the Apache web server development project.

Warning

The documents below have not been fully updated to take into account changes made in the 2.1 version of the Apache HTTP Server. Some of the information may still be relevant, but please use it with care.

Performance Notes - Apache Tuning

Notes about how to (run-time and compile-time) configure Apache for highest performance. Notes explaining why Apache does some things, and why it doesn't do other things (which make it slower/faster).

Security Tips

Some "do"s - and "don't"s - for keeping your Apache web site secure.

URL Rewriting Guide

This document supplements the mod_rewrite reference documentation. It describes how one can use Apache's mod_rewrite to solve typical URL-based problems webmasters are usually confronted with in practice.

Relevant Standards

This document acts as a reference page for most of the relevant standards that Apache follows.

Password Encryption Formats

Discussion of the various ciphers supported by Apache for authentication purposes.

misc/password_encryptions.html100644 0 0 22000 11237400230 14327 0ustar 0 0 Password Formats - Apache HTTP Server
<-

Password Formats

Notes about the password encryption formats generated and understood by Apache.

top

Basic Authentication

There are four formats that Apache recognizes for basic-authentication passwords. Note that not all formats work on every platform:

PLAIN TEXT (i.e. unencrypted)
Windows, BEOS, & Netware only.
CRYPT
Unix only. Uses the traditional Unix crypt(3) function with a randomly-generated 32-bit salt (only 12 bits used) and the first 8 characters of the password.
SHA1
"{SHA}" + Base64-encoded SHA-1 digest of the password.
MD5
"$apr1$" + the result of an Apache-specific algorithm using an iterated (1,000 times) MD5 digest of various combinations of a random 32-bit salt and the password. See the APR source file apr_md5.c for the details of the algorithm.

Generating values with htpasswd

MD5

$ htpasswd -nbm myName myPassword
myName:$apr1$r31.....$HqJZimcKQFAMYayBlzkrA/

SHA1

$ htpasswd -nbs myName myPassword
myName:{SHA}VBPuJHI7uixaa6LQGWx4s+5GKNE=

CRYPT

$ htpasswd -nbd myName myPassword
myName:rqXexS6ZhobKA

Generating CRYPT and MD5 values with the OpenSSL command-line program

OpenSSL knows the Apache-specific MD5 algorithm.

MD5

$ openssl passwd -apr1 myPassword
$apr1$qHDFfhPC$nITSVHgYbDAK1Y0acGRnY0

CRYPT

openssl passwd -crypt myPassword
qQ5vTYO3c8dsU

Validating CRYPT or MD5 passwords with the OpenSSL command line program

The salt for a CRYPT password is the first two characters (converted to a binary value). To validate myPassword against rqXexS6ZhobKA

CRYPT

$ openssl passwd -crypt -salt rq myPassword
Warning: truncating password to 8 characters
rqXexS6ZhobKA

Note that using myPasswo instead of myPassword will produce the same result because only the first 8 characters of CRYPT passwords are considered.

The salt for an MD5 password is between $apr1$ and the following $ (as a Base64-encoded binary value - max 8 chars). To validate myPassword against $apr1$r31.....$HqJZimcKQFAMYayBlzkrA/

MD5

$ openssl passwd -apr1 -salt r31..... myPassword
$apr1$r31.....$HqJZimcKQFAMYayBlzkrA/

Database password fields for mod_dbd

The SHA1 variant is probably the most useful format for DBD authentication. Since the SHA1 and Base64 functions are commonly available, other software can populate a database with encrypted passwords that are usable by Apache basic authentication.

To create Apache SHA1-variant basic-authentication passwords in various languages:

PHP

'{SHA}' . base64_encode(sha1($password, TRUE))

Java

"{SHA}" + new sun.misc.BASE64Encoder().encode(java.security.MessageDigest.getInstance("SHA1").digest(password.getBytes()))

ColdFusion

"{SHA}" & ToBase64(BinaryDecode(Hash(password, "SHA1"), "Hex"))

Ruby

require 'digest/sha1'
require 'base64'
'{SHA}' + Base64.encode64(Digest::SHA1.digest(password))

C or C++

Use the APR function: apr_sha1_base64

PostgreSQL (with the contrib/pgcrypto functions installed)

'{SHA}'||encode(digest(password,'sha1'),'base64')

top

Digest Authentication

Apache recognizes one format for digest-authentication passwords - the MD5 hash of the string user:realm:password as a 32-character string of hexadecimal digits. realm is the Authorization Realm argument to the AuthName directive in httpd.conf.

Database password fields for mod_dbd

Since the MD5 function is commonly available, other software can populate a database with encrypted passwords that are usable by Apache digest authentication.

To create Apache digest-authentication passwords in various languages:

PHP

md5($user . ':' . $realm . ':' .$password)

Java

byte b[] = java.security.MessageDigest.getInstance("MD5").digest( (user + ":" + realm + ":" + password ).getBytes());
java.math.BigInteger bi = new java.math.BigInteger(1, b);
String s = bi.toString(16);
while (s.length() < 32)
s = "0" + s; // String s is the encrypted password

ColdFusion

LCase(Hash( (user & ":" & realm & ":" & password) , "MD5"))

Ruby

require 'digest/md5'
Digest::MD5.hexdigest(user + ':' + realm + ':' + password)

PostgreSQL (with the contrib/pgcrypto functions installed)

encode(digest( user || ':' || realm || ':' || password , 'md5'), 'hex')

misc/perf-tuning.html100644 0 0 143776 11237400230 12336 0ustar 0 0 Apache Performance Tuning - Apache HTTP Server
<-

Apache Performance Tuning

Apache 2.x is a general-purpose webserver, designed to provide a balance of flexibility, portability, and performance. Although it has not been designed specifically to set benchmark records, Apache 2.x is capable of high performance in many real-world situations.

Compared to Apache 1.3, release 2.x contains many additional optimizations to increase throughput and scalability. Most of these improvements are enabled by default. However, there are compile-time and run-time configuration choices that can significantly affect performance. This document describes the options that a server administrator can configure to tune the performance of an Apache 2.x installation. Some of these configuration options enable the httpd to better take advantage of the capabilities of the hardware and OS, while others allow the administrator to trade functionality for speed.

top

Hardware and Operating System Issues

The single biggest hardware issue affecting webserver performance is RAM. A webserver should never ever have to swap, as swapping increases the latency of each request beyond a point that users consider "fast enough". This causes users to hit stop and reload, further increasing the load. You can, and should, control the MaxClients setting so that your server does not spawn so many children it starts swapping. This procedure for doing this is simple: determine the size of your average Apache process, by looking at your process list via a tool such as top, and divide this into your total available memory, leaving some room for other processes.

Beyond that the rest is mundane: get a fast enough CPU, a fast enough network card, and fast enough disks, where "fast enough" is something that needs to be determined by experimentation.

Operating system choice is largely a matter of local concerns. But some guidelines that have proven generally useful are:

  • Run the latest stable release and patchlevel of the operating system that you choose. Many OS suppliers have introduced significant performance improvements to their TCP stacks and thread libraries in recent years.

  • If your OS supports a sendfile(2) system call, make sure you install the release and/or patches needed to enable it. (With Linux, for example, this means using Linux 2.4 or later. For early releases of Solaris 8, you may need to apply a patch.) On systems where it is available, sendfile enables Apache 2 to deliver static content faster and with lower CPU utilization.

top

Run-Time Configuration Issues

HostnameLookups and other DNS considerations

Prior to Apache 1.3, HostnameLookups defaulted to On. This adds latency to every request because it requires a DNS lookup to complete before the request is finished. In Apache 1.3 this setting defaults to Off. If you need to have addresses in your log files resolved to hostnames, use the logresolve program that comes with Apache, or one of the numerous log reporting packages which are available.

It is recommended that you do this sort of postprocessing of your log files on some machine other than the production web server machine, in order that this activity not adversely affect server performance.

If you use any Allow from domain or Deny from domain directives (i.e., using a hostname, or a domain name, rather than an IP address) then you will pay for two DNS lookups (a reverse, followed by a forward lookup to make sure that the reverse is not being spoofed). For best performance, therefore, use IP addresses, rather than names, when using these directives, if possible.

Note that it's possible to scope the directives, such as within a <Location /server-status> section. In this case the DNS lookups are only performed on requests matching the criteria. Here's an example which disables lookups except for .html and .cgi files:

HostnameLookups off
<Files ~ "\.(html|cgi)$">
HostnameLookups on
</Files>

But even still, if you just need DNS names in some CGIs you could consider doing the gethostbyname call in the specific CGIs that need it.

FollowSymLinks and SymLinksIfOwnerMatch

Wherever in your URL-space you do not have an Options FollowSymLinks, or you do have an Options SymLinksIfOwnerMatch Apache will have to issue extra system calls to check up on symlinks. One extra call per filename component. For example, if you had:

DocumentRoot /www/htdocs
<Directory />
Options SymLinksIfOwnerMatch
</Directory>

and a request is made for the URI /index.html. Then Apache will perform lstat(2) on /www, /www/htdocs, and /www/htdocs/index.html. The results of these lstats are never cached, so they will occur on every single request. If you really desire the symlinks security checking you can do something like this:

DocumentRoot /www/htdocs
<Directory />
Options FollowSymLinks
</Directory>

<Directory /www/htdocs>
Options -FollowSymLinks +SymLinksIfOwnerMatch
</Directory>

This at least avoids the extra checks for the DocumentRoot path. Note that you'll need to add similar sections if you have any Alias or RewriteRule paths outside of your document root. For highest performance, and no symlink protection, set FollowSymLinks everywhere, and never set SymLinksIfOwnerMatch.

AllowOverride

Wherever in your URL-space you allow overrides (typically .htaccess files) Apache will attempt to open .htaccess for each filename component. For example,

DocumentRoot /www/htdocs
<Directory />
AllowOverride all
</Directory>

and a request is made for the URI /index.html. Then Apache will attempt to open /.htaccess, /www/.htaccess, and /www/htdocs/.htaccess. The solutions are similar to the previous case of Options FollowSymLinks. For highest performance use AllowOverride None everywhere in your filesystem.

Negotiation

If at all possible, avoid content-negotiation if you're really interested in every last ounce of performance. In practice the benefits of negotiation outweigh the performance penalties. There's one case where you can speed up the server. Instead of using a wildcard such as:

DirectoryIndex index

Use a complete list of options:

DirectoryIndex index.cgi index.pl index.shtml index.html

where you list the most common choice first.

Also note that explicitly creating a type-map file provides better performance than using MultiViews, as the necessary information can be determined by reading this single file, rather than having to scan the directory for files.

If your site needs content negotiation consider using type-map files, rather than the Options MultiViews directive to accomplish the negotiation. See the Content Negotiation documentation for a full discussion of the methods of negotiation, and instructions for creating type-map files.

Memory-mapping

In situations where Apache 2.x needs to look at the contents of a file being delivered--for example, when doing server-side-include processing--it normally memory-maps the file if the OS supports some form of mmap(2).

On some platforms, this memory-mapping improves performance. However, there are cases where memory-mapping can hurt the performance or even the stability of the httpd:

  • On some operating systems, mmap does not scale as well as read(2) when the number of CPUs increases. On multiprocessor Solaris servers, for example, Apache 2.x sometimes delivers server-parsed files faster when mmap is disabled.

  • If you memory-map a file located on an NFS-mounted filesystem and a process on another NFS client machine deletes or truncates the file, your process may get a bus error the next time it tries to access the mapped file content.

For installations where either of these factors applies, you should use EnableMMAP off to disable the memory-mapping of delivered files. (Note: This directive can be overridden on a per-directory basis.)

Sendfile

In situations where Apache 2.x can ignore the contents of the file to be delivered -- for example, when serving static file content -- it normally uses the kernel sendfile support the file if the OS supports the sendfile(2) operation.

On most platforms, using sendfile improves performance by eliminating separate read and send mechanics. However, there are cases where using sendfile can harm the stability of the httpd:

  • Some platforms may have broken sendfile support that the build system did not detect, especially if the binaries were built on another box and moved to such a machine with broken sendfile support.

  • With an NFS-mounted files, the kernel may be unable to reliably serve the network file through it's own cache.

For installations where either of these factors applies, you should use EnableSendfile off to disable sendfile delivery of file contents. (Note: This directive can be overridden on a per-directory basis.)

Process Creation

Prior to Apache 1.3 the MinSpareServers, MaxSpareServers, and StartServers settings all had drastic effects on benchmark results. In particular, Apache required a "ramp-up" period in order to reach a number of children sufficient to serve the load being applied. After the initial spawning of StartServers children, only one child per second would be created to satisfy the MinSpareServers setting. So a server being accessed by 100 simultaneous clients, using the default StartServers of 5 would take on the order 95 seconds to spawn enough children to handle the load. This works fine in practice on real-life servers, because they aren't restarted frequently. But does really poorly on benchmarks which might only run for ten minutes.

The one-per-second rule was implemented in an effort to avoid swamping the machine with the startup of new children. If the machine is busy spawning children it can't service requests. But it has such a drastic effect on the perceived performance of Apache that it had to be replaced. As of Apache 1.3, the code will relax the one-per-second rule. It will spawn one, wait a second, then spawn two, wait a second, then spawn four, and it will continue exponentially until it is spawning 32 children per second. It will stop whenever it satisfies the MinSpareServers setting.

This appears to be responsive enough that it's almost unnecessary to twiddle the MinSpareServers, MaxSpareServers and StartServers knobs. When more than 4 children are spawned per second, a message will be emitted to the ErrorLog. If you see a lot of these errors then consider tuning these settings. Use the mod_status output as a guide.

Related to process creation is process death induced by the MaxRequestsPerChild setting. By default this is 0, which means that there is no limit to the number of requests handled per child. If your configuration currently has this set to some very low number, such as 30, you may want to bump this up significantly. If you are running SunOS or an old version of Solaris, limit this to 10000 or so because of memory leaks.

When keep-alives are in use, children will be kept busy doing nothing waiting for more requests on the already open connection. The default KeepAliveTimeout of 5 seconds attempts to minimize this effect. The tradeoff here is between network bandwidth and server resources. In no event should you raise this above about 60 seconds, as most of the benefits are lost.

top

Compile-Time Configuration Issues

Choosing an MPM

Apache 2.x supports pluggable concurrency models, called Multi-Processing Modules (MPMs). When building Apache, you must choose an MPM to use. There are platform-specific MPMs for some platforms: beos, mpm_netware, mpmt_os2, and mpm_winnt. For general Unix-type systems, there are several MPMs from which to choose. The choice of MPM can affect the speed and scalability of the httpd:

  • The worker MPM uses multiple child processes with many threads each. Each thread handles one connection at a time. Worker generally is a good choice for high-traffic servers because it has a smaller memory footprint than the prefork MPM.
  • The prefork MPM uses multiple child processes with one thread each. Each process handles one connection at a time. On many systems, prefork is comparable in speed to worker, but it uses more memory. Prefork's threadless design has advantages over worker in some situations: it can be used with non-thread-safe third-party modules, and it is easier to debug on platforms with poor thread debugging support.

For more information on these and other MPMs, please see the MPM documentation.

Modules

Since memory usage is such an important consideration in performance, you should attempt to eliminate modules that you are not actually using. If you have built the modules as DSOs, eliminating modules is a simple matter of commenting out the associated LoadModule directive for that module. This allows you to experiment with removing modules, and seeing if your site still functions in their absense.

If, on the other hand, you have modules statically linked into your Apache binary, you will need to recompile Apache in order to remove unwanted modules.

An associated question that arises here is, of course, what modules you need, and which ones you don't. The answer here will, of course, vary from one web site to another. However, the minimal list of modules which you can get by with tends to include mod_mime, mod_dir, and mod_log_config. mod_log_config is, of course, optional, as you can run a web site without log files. This is, however, not recommended.

Atomic Operations

Some modules, such as mod_cache and recent development builds of the worker MPM, use APR's atomic API. This API provides atomic operations that can be used for lightweight thread synchronization.

By default, APR implements these operations using the most efficient mechanism available on each target OS/CPU platform. Many modern CPUs, for example, have an instruction that does an atomic compare-and-swap (CAS) operation in hardware. On some platforms, however, APR defaults to a slower, mutex-based implementation of the atomic API in order to ensure compatibility with older CPU models that lack such instructions. If you are building Apache for one of these platforms, and you plan to run only on newer CPUs, you can select a faster atomic implementation at build time by configuring Apache with the --enable-nonportable-atomics option:

./buildconf
./configure --with-mpm=worker --enable-nonportable-atomics=yes

The --enable-nonportable-atomics option is relevant for the following platforms:

  • Solaris on SPARC
    By default, APR uses mutex-based atomics on Solaris/SPARC. If you configure with --enable-nonportable-atomics, however, APR generates code that uses a SPARC v8plus opcode for fast hardware compare-and-swap. If you configure Apache with this option, the atomic operations will be more efficient (allowing for lower CPU utilization and higher concurrency), but the resulting executable will run only on UltraSPARC chips.
  • Linux on x86
    By default, APR uses mutex-based atomics on Linux. If you configure with --enable-nonportable-atomics, however, APR generates code that uses a 486 opcode for fast hardware compare-and-swap. This will result in more efficient atomic operations, but the resulting executable will run only on 486 and later chips (and not on 386).

mod_status and ExtendedStatus On

If you include mod_status and you also set ExtendedStatus On when building and running Apache, then on every request Apache will perform two calls to gettimeofday(2) (or times(2) depending on your operating system), and (pre-1.3) several extra calls to time(2). This is all done so that the status report contains timing indications. For highest performance, set ExtendedStatus off (which is the default).

accept Serialization - multiple sockets

Warning:

This section has not been fully updated to take into account changes made in the 2.x version of the Apache HTTP Server. Some of the information may still be relevant, but please use it with care.

This discusses a shortcoming in the Unix socket API. Suppose your web server uses multiple Listen statements to listen on either multiple ports or multiple addresses. In order to test each socket to see if a connection is ready Apache uses select(2). select(2) indicates that a socket has zero or at least one connection waiting on it. Apache's model includes multiple children, and all the idle ones test for new connections at the same time. A naive implementation looks something like this (these examples do not match the code, they're contrived for pedagogical purposes):

for (;;) {
for (;;) {
fd_set accept_fds;

FD_ZERO (&accept_fds);
for (i = first_socket; i <= last_socket; ++i) {
FD_SET (i, &accept_fds);
}
rc = select (last_socket+1, &accept_fds, NULL, NULL, NULL);
if (rc < 1) continue;
new_connection = -1;
for (i = first_socket; i <= last_socket; ++i) {
if (FD_ISSET (i, &accept_fds)) {
new_connection = accept (i, NULL, NULL);
if (new_connection != -1) break;
}
}
if (new_connection != -1) break;
}
process the new_connection;
}

But this naive implementation has a serious starvation problem. Recall that multiple children execute this loop at the same time, and so multiple children will block at select when they are in between requests. All those blocked children will awaken and return from select when a single request appears on any socket (the number of children which awaken varies depending on the operating system and timing issues). They will all then fall down into the loop and try to accept the connection. But only one will succeed (assuming there's still only one connection ready), the rest will be blocked in accept. This effectively locks those children into serving requests from that one socket and no other sockets, and they'll be stuck there until enough new requests appear on that socket to wake them all up. This starvation problem was first documented in PR#467. There are at least two solutions.

One solution is to make the sockets non-blocking. In this case the accept won't block the children, and they will be allowed to continue immediately. But this wastes CPU time. Suppose you have ten idle children in select, and one connection arrives. Then nine of those children will wake up, try to accept the connection, fail, and loop back into select, accomplishing nothing. Meanwhile none of those children are servicing requests that occurred on other sockets until they get back up to the select again. Overall this solution does not seem very fruitful unless you have as many idle CPUs (in a multiprocessor box) as you have idle children, not a very likely situation.

Another solution, the one used by Apache, is to serialize entry into the inner loop. The loop looks like this (differences highlighted):

for (;;) {
accept_mutex_on ();
for (;;) {
fd_set accept_fds;

FD_ZERO (&accept_fds);
for (i = first_socket; i <= last_socket; ++i) {
FD_SET (i, &accept_fds);
}
rc = select (last_socket+1, &accept_fds, NULL, NULL, NULL);
if (rc < 1) continue;
new_connection = -1;
for (i = first_socket; i <= last_socket; ++i) {
if (FD_ISSET (i, &accept_fds)) {
new_connection = accept (i, NULL, NULL);
if (new_connection != -1) break;
}
}
if (new_connection != -1) break;
}
accept_mutex_off ();
process the new_connection;
}

The functions accept_mutex_on and accept_mutex_off implement a mutual exclusion semaphore. Only one child can have the mutex at any time. There are several choices for implementing these mutexes. The choice is defined in src/conf.h (pre-1.3) or src/include/ap_config.h (1.3 or later). Some architectures do not have any locking choice made, on these architectures it is unsafe to use multiple Listen directives.

The directive AcceptMutex can be used to change the selected mutex implementation at run-time.

AcceptMutex flock

This method uses the flock(2) system call to lock a lock file (located by the LockFile directive).

AcceptMutex fcntl

This method uses the fcntl(2) system call to lock a lock file (located by the LockFile directive).

AcceptMutex sysvsem

(1.3 or later) This method uses SysV-style semaphores to implement the mutex. Unfortunately SysV-style semaphores have some bad side-effects. One is that it's possible Apache will die without cleaning up the semaphore (see the ipcs(8) man page). The other is that the semaphore API allows for a denial of service attack by any CGIs running under the same uid as the webserver (i.e., all CGIs, unless you use something like suexec or cgiwrapper). For these reasons this method is not used on any architecture except IRIX (where the previous two are prohibitively expensive on most IRIX boxes).

AcceptMutex pthread

(1.3 or later) This method uses POSIX mutexes and should work on any architecture implementing the full POSIX threads specification, however appears to only work on Solaris (2.5 or later), and even then only in certain configurations. If you experiment with this you should watch out for your server hanging and not responding. Static content only servers may work just fine.

AcceptMutex posixsem

(2.0 or later) This method uses POSIX semaphores. The semaphore ownership is not recovered if a thread in the process holding the mutex segfaults, resulting in a hang of the web server.

If your system has another method of serialization which isn't in the above list then it may be worthwhile adding code for it to APR.

Another solution that has been considered but never implemented is to partially serialize the loop -- that is, let in a certain number of processes. This would only be of interest on multiprocessor boxes where it's possible multiple children could run simultaneously, and the serialization actually doesn't take advantage of the full bandwidth. This is a possible area of future investigation, but priority remains low because highly parallel web servers are not the norm.

Ideally you should run servers without multiple Listen statements if you want the highest performance. But read on.

accept Serialization - single socket

The above is fine and dandy for multiple socket servers, but what about single socket servers? In theory they shouldn't experience any of these same problems because all children can just block in accept(2) until a connection arrives, and no starvation results. In practice this hides almost the same "spinning" behaviour discussed above in the non-blocking solution. The way that most TCP stacks are implemented, the kernel actually wakes up all processes blocked in accept when a single connection arrives. One of those processes gets the connection and returns to user-space, the rest spin in the kernel and go back to sleep when they discover there's no connection for them. This spinning is hidden from the user-land code, but it's there nonetheless. This can result in the same load-spiking wasteful behaviour that a non-blocking solution to the multiple sockets case can.

For this reason we have found that many architectures behave more "nicely" if we serialize even the single socket case. So this is actually the default in almost all cases. Crude experiments under Linux (2.0.30 on a dual Pentium pro 166 w/128Mb RAM) have shown that the serialization of the single socket case causes less than a 3% decrease in requests per second over unserialized single-socket. But unserialized single-socket showed an extra 100ms latency on each request. This latency is probably a wash on long haul lines, and only an issue on LANs. If you want to override the single socket serialization you can define SINGLE_LISTEN_UNSERIALIZED_ACCEPT and then single-socket servers will not serialize at all.

Lingering Close

As discussed in draft-ietf-http-connection-00.txt section 8, in order for an HTTP server to reliably implement the protocol it needs to shutdown each direction of the communication independently (recall that a TCP connection is bi-directional, each half is independent of the other). This fact is often overlooked by other servers, but is correctly implemented in Apache as of 1.2.

When this feature was added to Apache it caused a flurry of problems on various versions of Unix because of a shortsightedness. The TCP specification does not state that the FIN_WAIT_2 state has a timeout, but it doesn't prohibit it. On systems without the timeout, Apache 1.2 induces many sockets stuck forever in the FIN_WAIT_2 state. In many cases this can be avoided by simply upgrading to the latest TCP/IP patches supplied by the vendor. In cases where the vendor has never released patches (i.e., SunOS4 -- although folks with a source license can patch it themselves) we have decided to disable this feature.

There are two ways of accomplishing this. One is the socket option SO_LINGER. But as fate would have it, this has never been implemented properly in most TCP/IP stacks. Even on those stacks with a proper implementation (i.e., Linux 2.0.31) this method proves to be more expensive (cputime) than the next solution.

For the most part, Apache implements this in a function called lingering_close (in http_main.c). The function looks roughly like this:

void lingering_close (int s)
{
char junk_buffer[2048];

/* shutdown the sending side */
shutdown (s, 1);

signal (SIGALRM, lingering_death);
alarm (30);

for (;;) {
select (s for reading, 2 second timeout);
if (error) break;
if (s is ready for reading) {
if (read (s, junk_buffer, sizeof (junk_buffer)) <= 0) {
break;
}
/* just toss away whatever is here */
}
}

close (s);
}

This naturally adds some expense at the end of a connection, but it is required for a reliable implementation. As HTTP/1.1 becomes more prevalent, and all connections are persistent, this expense will be amortized over more requests. If you want to play with fire and disable this feature you can define NO_LINGCLOSE, but this is not recommended at all. In particular, as HTTP/1.1 pipelined persistent connections come into use lingering_close is an absolute necessity (and pipelined connections are faster, so you want to support them).

Scoreboard File

Apache's parent and children communicate with each other through something called the scoreboard. Ideally this should be implemented in shared memory. For those operating systems that we either have access to, or have been given detailed ports for, it typically is implemented using shared memory. The rest default to using an on-disk file. The on-disk file is not only slow, but it is unreliable (and less featured). Peruse the src/main/conf.h file for your architecture and look for either USE_MMAP_SCOREBOARD or USE_SHMGET_SCOREBOARD. Defining one of those two (as well as their companions HAVE_MMAP and HAVE_SHMGET respectively) enables the supplied shared memory code. If your system has another type of shared memory, edit the file src/main/http_main.c and add the hooks necessary to use it in Apache. (Send us back a patch too please.)

Historical note: The Linux port of Apache didn't start to use shared memory until version 1.2 of Apache. This oversight resulted in really poor and unreliable behaviour of earlier versions of Apache on Linux.

DYNAMIC_MODULE_LIMIT

If you have no intention of using dynamically loaded modules (you probably don't if you're reading this and tuning your server for every last ounce of performance) then you should add -DDYNAMIC_MODULE_LIMIT=0 when building your server. This will save RAM that's allocated only for supporting dynamically loaded modules.

top

Appendix: Detailed Analysis of a Trace

Here is a system call trace of Apache 2.0.38 with the worker MPM on Solaris 8. This trace was collected using:

truss -l -p httpd_child_pid.

The -l option tells truss to log the ID of the LWP (lightweight process--Solaris's form of kernel-level thread) that invokes each system call.

Other systems may have different system call tracing utilities such as strace, ktrace, or par. They all produce similar output.

In this trace, a client has requested a 10KB static file from the httpd. Traces of non-static requests or requests with content negotiation look wildly different (and quite ugly in some cases).

/67:    accept(3, 0x00200BEC, 0x00200C0C, 1) (sleeping...)
/67:    accept(3, 0x00200BEC, 0x00200C0C, 1)            = 9

In this trace, the listener thread is running within LWP #67.

Note the lack of accept(2) serialization. On this particular platform, the worker MPM uses an unserialized accept by default unless it is listening on multiple ports.
/65:    lwp_park(0x00000000, 0)                         = 0
/67:    lwp_unpark(65, 1)                               = 0

Upon accepting the connection, the listener thread wakes up a worker thread to do the request processing. In this trace, the worker thread that handles the request is mapped to LWP #65.

/65:    getsockname(9, 0x00200BA4, 0x00200BC4, 1)       = 0

In order to implement virtual hosts, Apache needs to know the local socket address used to accept the connection. It is possible to eliminate this call in many situations (such as when there are no virtual hosts, or when Listen directives are used which do not have wildcard addresses). But no effort has yet been made to do these optimizations.

/65:    brk(0x002170E8)                                 = 0
/65:    brk(0x002190E8)                                 = 0

The brk(2) calls allocate memory from the heap. It is rare to see these in a system call trace, because the httpd uses custom memory allocators (apr_pool and apr_bucket_alloc) for most request processing. In this trace, the httpd has just been started, so it must call malloc(3) to get the blocks of raw memory with which to create the custom memory allocators.

/65:    fcntl(9, F_GETFL, 0x00000000)                   = 2
/65:    fstat64(9, 0xFAF7B818)                          = 0
/65:    getsockopt(9, 65535, 8192, 0xFAF7B918, 0xFAF7B910, 2190656) = 0
/65:    fstat64(9, 0xFAF7B818)                          = 0
/65:    getsockopt(9, 65535, 8192, 0xFAF7B918, 0xFAF7B914, 2190656) = 0
/65:    setsockopt(9, 65535, 8192, 0xFAF7B918, 4, 2190656) = 0
/65:    fcntl(9, F_SETFL, 0x00000082)                   = 0

Next, the worker thread puts the connection to the client (file descriptor 9) in non-blocking mode. The setsockopt(2) and getsockopt(2) calls are a side-effect of how Solaris's libc handles fcntl(2) on sockets.

/65:    read(9, " G E T   / 1 0 k . h t m".., 8000)     = 97

The worker thread reads the request from the client.

/65:    stat("/var/httpd/apache/httpd-8999/htdocs/10k.html", 0xFAF7B978) = 0
/65:    open("/var/httpd/apache/httpd-8999/htdocs/10k.html", O_RDONLY) = 10

This httpd has been configured with Options FollowSymLinks and AllowOverride None. Thus it doesn't need to lstat(2) each directory in the path leading up to the requested file, nor check for .htaccess files. It simply calls stat(2) to verify that the file: 1) exists, and 2) is a regular file, not a directory.

/65:    sendfilev(0, 9, 0x00200F90, 2, 0xFAF7B53C)      = 10269

In this example, the httpd is able to send the HTTP response header and the requested file with a single sendfilev(2) system call. Sendfile semantics vary among operating systems. On some other systems, it is necessary to do a write(2) or writev(2) call to send the headers before calling sendfile(2).

/65:    write(4, " 1 2 7 . 0 . 0 . 1   -  ".., 78)      = 78

This write(2) call records the request in the access log. Note that one thing missing from this trace is a time(2) call. Unlike Apache 1.3, Apache 2.x uses gettimeofday(3) to look up the time. On some operating systems, like Linux or Solaris, gettimeofday has an optimized implementation that doesn't require as much overhead as a typical system call.

/65:    shutdown(9, 1, 1)                               = 0
/65:    poll(0xFAF7B980, 1, 2000)                       = 1
/65:    read(9, 0xFAF7BC20, 512)                        = 0
/65:    close(9)                                        = 0

The worker thread does a lingering close of the connection.

/65:    close(10)                                       = 0
/65:    lwp_park(0x00000000, 0)         (sleeping...)

Finally the worker thread closes the file that it has just delivered and blocks until the listener assigns it another connection.

/67:    accept(3, 0x001FEB74, 0x001FEB94, 1) (sleeping...)

Meanwhile, the listener thread is able to accept another connection as soon as it has dispatched this connection to a worker thread (subject to some flow-control logic in the worker MPM that throttles the listener if all the available workers are busy). Though it isn't apparent from this trace, the next accept(2) can (and usually does, under high load conditions) occur in parallel with the worker thread's handling of the just-accepted connection.

misc/relevant_standards.html100644 0 0 21375 11237400230 13731 0ustar 0 0 Relevant Standards - Apache HTTP Server
<-

Relevant Standards

This page documents all the relevant standards that the Apache HTTP Server follows, along with brief descriptions.

In addition to the information listed below, the following resources should be consulted:

Notice

This document is not yet complete.

top

HTTP Recommendations

Regardless of what modules are compiled and used, Apache as a basic web server complies with the following IETF recommendations:

RFC 1945 (Informational)
The Hypertext Transfer Protocol (HTTP) is an application-level protocol with the lightness and speed necessary for distributed, collaborative, hypermedia information systems. This documents HTTP/1.0.
RFC 2616 (Standards Track)
The Hypertext Transfer Protocol (HTTP) is an application-level protocol for distributed, collaborative, hypermedia information systems. This documents HTTP/1.1.
RFC 2396 (Standards Track)
A Uniform Resource Identifier (URI) is a compact string of characters for identifying an abstract or physical resource.
top

HTML Recommendations

Regarding the Hypertext Markup Language, Apache complies with the following IETF and W3C recommendations:

RFC 2854 (Informational)
This document summarizes the history of HTML development, and defines the "text/html" MIME type by pointing to the relevant W3C recommendations.
HTML 4.01 Specification (Errata)
This specification defines the HyperText Markup Language (HTML), the publishing language of the World Wide Web. This specification defines HTML 4.01, which is a subversion of HTML 4.
HTML 3.2 Reference Specification
The HyperText Markup Language (HTML) is a simple markup language used to create hypertext documents that are portable from one platform to another. HTML documents are SGML documents.
XHTML 1.1 - Module-based XHTML (Errata)
This Recommendation defines a new XHTML document type that is based upon the module framework and modules defined in Modularization of XHTML.
XHTML 1.0 The Extensible HyperText Markup Language (Second Edition) (Errata)
This specification defines the Second Edition of XHTML 1.0, a reformulation of HTML 4 as an XML 1.0 application, and three DTDs corresponding to the ones defined by HTML 4.
top

Authentication

Concerning the different methods of authentication, Apache follows the following IETF recommendations:

RFC 2617 (Draft standard)
"HTTP/1.0", includes the specification for a Basic Access Authentication scheme.
top

Language/Country Codes

The following links document ISO and other language and country code information:

ISO 639-2
ISO 639 provides two sets of language codes, one as a two-letter code set (639-1) and another as a three-letter code set (this part of ISO 639) for the representation of names of languages.
ISO 3166-1
These pages document the country names (official short names in English) in alphabetical order as given in ISO 3166-1 and the corresponding ISO 3166-1-alpha-2 code elements.
BCP 47 (Best Current Practice), RFC 3066
This document describes a language tag for use in cases where it is desired to indicate the language used in an information object, how to register values for use in this language tag, and a construct for matching such language tags.
RFC 3282 (Standards Track)
This document defines a "Content-language:" header, for use in cases where one desires to indicate the language of something that has RFC 822-like headers, like MIME body parts or Web documents, and an "Accept-Language:" header for use in cases where one wishes to indicate one's preferences with regard to language.
misc/rewriteguide.html100644 0 0 212141 11237400230 12556 0ustar 0 0 URL Rewriting Guide - Apache HTTP Server
<-

URL Rewriting Guide

This document is obsolete. It has been replaced with a new Rewrite Guide.

Originally written by
Ralf S. Engelschall <rse@apache.org>
December 1997

This document supplements the mod_rewrite reference documentation. It describes how one can use Apache's mod_rewrite to solve typical URL-based problems with which webmasters are commonly confronted. We give detailed descriptions on how to solve each problem by configuring URL rewriting rulesets.

top

Introduction to mod_rewrite

The Apache module mod_rewrite is a killer one, i.e. it is a really sophisticated module which provides a powerful way to do URL manipulations. With it you can do nearly all types of URL manipulations you ever dreamed about. The price you have to pay is to accept complexity, because mod_rewrite's major drawback is that it is not easy to understand and use for the beginner. And even Apache experts sometimes discover new aspects where mod_rewrite can help.

In other words: With mod_rewrite you either shoot yourself in the foot the first time and never use it again or love it for the rest of your life because of its power. This paper tries to give you a few initial success events to avoid the first case by presenting already invented solutions to you.

top

Practical Solutions

Here come a lot of practical solutions I've either invented myself or collected from other people's solutions in the past. Feel free to learn the black magic of URL rewriting from these examples.

ATTENTION: Depending on your server-configuration it can be necessary to slightly change the examples for your situation, e.g. adding the [PT] flag when additionally using mod_alias and mod_userdir, etc. Or rewriting a ruleset to fit in .htaccess context instead of per-server context. Always try to understand what a particular ruleset really does before you use it. It avoid problems.
top

URL Layout

Canonical URLs

Description:

On some webservers there are more than one URL for a resource. Usually there are canonical URLs (which should be actually used and distributed) and those which are just shortcuts, internal ones, etc. Independent of which URL the user supplied with the request he should finally see the canonical one only.

Solution:

We do an external HTTP redirect for all non-canonical URLs to fix them in the location view of the Browser and for all subsequent requests. In the example ruleset below we replace /~user by the canonical /u/user and fix a missing trailing slash for /u/user.

RewriteRule   ^/~([^/]+)/?(.*)    /u/$1/$2  [R]
RewriteRule   ^/u/([^/]+)$  /$1/$2/   [R]

Canonical Hostnames

Description:
The goal of this rule is to force the use of a particular hostname, in preference to other hostnames which may be used to reach the same site. For example, if you wish to force the use of www.example.com instead of example.com, you might use a variant of the following recipe.
Solution:
# To force the use of 
RewriteEngine On
RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://www.example.com/$1 [L,R]

Moved DocumentRoot

Description:

Usually the DocumentRoot of the webserver directly relates to the URL "/". But often this data is not really of top-level priority, it is perhaps just one entity of a lot of data pools. For instance at our Intranet sites there are /e/www/ (the homepage for WWW), /e/sww/ (the homepage for the Intranet) etc. Now because the data of the DocumentRoot stays at /e/www/ we had to make sure that all inlined images and other stuff inside this data pool work for subsequent requests.

Solution:

We redirect the URL / to /e/www/:

RewriteEngine on
RewriteRule   ^/$  /e/www/  [R]

Note that this can also be handled using the RedirectMatch directive:

RedirectMatch ^/$ http://example.com/e/www/

Trailing Slash Problem

Description:

Every webmaster can sing a song about the problem of the trailing slash on URLs referencing directories. If they are missing, the server dumps an error, because if you say /~quux/foo instead of /~quux/foo/ then the server searches for a file named foo. And because this file is a directory it complains. Actually it tries to fix it itself in most of the cases, but sometimes this mechanism need to be emulated by you. For instance after you have done a lot of complicated URL rewritings to CGI scripts etc.

Solution:

The solution to this subtle problem is to let the server add the trailing slash automatically. To do this correctly we have to use an external redirect, so the browser correctly requests subsequent images etc. If we only did a internal rewrite, this would only work for the directory page, but would go wrong when any images are included into this page with relative URLs, because the browser would request an in-lined object. For instance, a request for image.gif in /~quux/foo/index.html would become /~quux/image.gif without the external redirect!

So, to do this trick we write:

RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^foo$  foo/  [R]

The crazy and lazy can even do the following in the top-level .htaccess file of their homedir. But notice that this creates some processing overhead.

RewriteEngine  on
RewriteBase    /~quux/
RewriteCond    %{REQUEST_FILENAME}  -d
RewriteRule    ^(.+[^/])$           $1/  [R]

Webcluster through Homogeneous URL Layout

Description:

We want to create a homogeneous and consistent URL layout over all WWW servers on a Intranet webcluster, i.e. all URLs (per definition server local and thus server dependent!) become actually server independent! What we want is to give the WWW namespace a consistent server-independent layout: no URL should have to include any physically correct target server. The cluster itself should drive us automatically to the physical target host.

Solution:

First, the knowledge of the target servers come from (distributed) external maps which contain information where our users, groups and entities stay. The have the form

user1  server_of_user1
user2  server_of_user2
:      :

We put them into files map.xxx-to-host. Second we need to instruct all servers to redirect URLs of the forms

/u/user/anypath
/g/group/anypath
/e/entity/anypath

to

http://physical-host/u/user/anypath
http://physical-host/g/group/anypath
http://physical-host/e/entity/anypath

when the URL is not locally valid to a server. The following ruleset does this for us by the help of the map files (assuming that server0 is a default server which will be used if a user has no entry in the map):

RewriteEngine on

RewriteMap      user-to-host   txt:/path/to/map.user-to-host
RewriteMap     group-to-host   txt:/path/to/map.group-to-host
RewriteMap    entity-to-host   txt:/path/to/map.entity-to-host

RewriteRule   ^/u/([^/]+)/?(.*)   http://${user-to-host:$1|server0}/u/$1/$2
RewriteRule   ^/g/([^/]+)/?(.*)  http://${group-to-host:$1|server0}/g/$1/$2
RewriteRule   ^/e/([^/]+)/?(.*) http://${entity-to-host:$1|server0}/e/$1/$2

RewriteRule   ^/([uge])/([^/]+)/?$          /$1/$2/.www/
RewriteRule   ^/([uge])/([^/]+)/([^.]+.+)   /$1/$2/.www/$3\

Move Homedirs to Different Webserver

Description:

Many webmasters have asked for a solution to the following situation: They wanted to redirect just all homedirs on a webserver to another webserver. They usually need such things when establishing a newer webserver which will replace the old one over time.

Solution:

The solution is trivial with mod_rewrite. On the old webserver we just redirect all /~user/anypath URLs to http://newserver/~user/anypath.

RewriteEngine on
RewriteRule   ^/~(.+)  http://newserver/~$1  [R,L]

Structured Homedirs

Description:

Some sites with thousands of users usually use a structured homedir layout, i.e. each homedir is in a subdirectory which begins for instance with the first character of the username. So, /~foo/anypath is /home/f/foo/.www/anypath while /~bar/anypath is /home/b/bar/.www/anypath.

Solution:

We use the following ruleset to expand the tilde URLs into exactly the above layout.

RewriteEngine on
RewriteRule   ^/~(([a-z])[a-z0-9]+)(.*)  /home/$2/$1/.www$3

Filesystem Reorganization

Description:

This really is a hardcore example: a killer application which heavily uses per-directory RewriteRules to get a smooth look and feel on the Web while its data structure is never touched or adjusted. Background: net.sw is my archive of freely available Unix software packages, which I started to collect in 1992. It is both my hobby and job to to this, because while I'm studying computer science I have also worked for many years as a system and network administrator in my spare time. Every week I need some sort of software so I created a deep hierarchy of directories where I stored the packages:

drwxrwxr-x   2 netsw  users    512 Aug  3 18:39 Audio/
drwxrwxr-x   2 netsw  users    512 Jul  9 14:37 Benchmark/
drwxrwxr-x  12 netsw  users    512 Jul  9 00:34 Crypto/
drwxrwxr-x   5 netsw  users    512 Jul  9 00:41 Database/
drwxrwxr-x   4 netsw  users    512 Jul 30 19:25 Dicts/
drwxrwxr-x  10 netsw  users    512 Jul  9 01:54 Graphic/
drwxrwxr-x   5 netsw  users    512 Jul  9 01:58 Hackers/
drwxrwxr-x   8 netsw  users    512 Jul  9 03:19 InfoSys/
drwxrwxr-x   3 netsw  users    512 Jul  9 03:21 Math/
drwxrwxr-x   3 netsw  users    512 Jul  9 03:24 Misc/
drwxrwxr-x   9 netsw  users    512 Aug  1 16:33 Network/
drwxrwxr-x   2 netsw  users    512 Jul  9 05:53 Office/
drwxrwxr-x   7 netsw  users    512 Jul  9 09:24 SoftEng/
drwxrwxr-x   7 netsw  users    512 Jul  9 12:17 System/
drwxrwxr-x  12 netsw  users    512 Aug  3 20:15 Typesetting/
drwxrwxr-x  10 netsw  users    512 Jul  9 14:08 X11/

In July 1996 I decided to make this archive public to the world via a nice Web interface. "Nice" means that I wanted to offer an interface where you can browse directly through the archive hierarchy. And "nice" means that I didn't wanted to change anything inside this hierarchy - not even by putting some CGI scripts at the top of it. Why? Because the above structure should be later accessible via FTP as well, and I didn't want any Web or CGI stuff to be there.

Solution:

The solution has two parts: The first is a set of CGI scripts which create all the pages at all directory levels on-the-fly. I put them under /e/netsw/.www/ as follows:

-rw-r--r--   1 netsw  users    1318 Aug  1 18:10 .wwwacl
drwxr-xr-x  18 netsw  users     512 Aug  5 15:51 DATA/
-rw-rw-rw-   1 netsw  users  372982 Aug  5 16:35 LOGFILE
-rw-r--r--   1 netsw  users     659 Aug  4 09:27 TODO
-rw-r--r--   1 netsw  users    5697 Aug  1 18:01 netsw-about.html
-rwxr-xr-x   1 netsw  users     579 Aug  2 10:33 netsw-access.pl
-rwxr-xr-x   1 netsw  users    1532 Aug  1 17:35 netsw-changes.cgi
-rwxr-xr-x   1 netsw  users    2866 Aug  5 14:49 netsw-home.cgi
drwxr-xr-x   2 netsw  users     512 Jul  8 23:47 netsw-img/
-rwxr-xr-x   1 netsw  users   24050 Aug  5 15:49 netsw-lsdir.cgi
-rwxr-xr-x   1 netsw  users    1589 Aug  3 18:43 netsw-search.cgi
-rwxr-xr-x   1 netsw  users    1885 Aug  1 17:41 netsw-tree.cgi
-rw-r--r--   1 netsw  users     234 Jul 30 16:35 netsw-unlimit.lst

The DATA/ subdirectory holds the above directory structure, i.e. the real net.sw stuff and gets automatically updated via rdist from time to time. The second part of the problem remains: how to link these two structures together into one smooth-looking URL tree? We want to hide the DATA/ directory from the user while running the appropriate CGI scripts for the various URLs. Here is the solution: first I put the following into the per-directory configuration file in the DocumentRoot of the server to rewrite the announced URL /net.sw/ to the internal path /e/netsw:

RewriteRule  ^net.sw$       net.sw/        [R]
RewriteRule  ^net.sw/(.*)$  e/netsw/$1

The first rule is for requests which miss the trailing slash! The second rule does the real thing. And then comes the killer configuration which stays in the per-directory config file /e/netsw/.www/.wwwacl:

Options       ExecCGI FollowSymLinks Includes MultiViews

RewriteEngine on

#  we are reached via /net.sw/ prefix
RewriteBase   /net.sw/

#  first we rewrite the root dir to
#  the handling cgi script
RewriteRule   ^$                       netsw-home.cgi     [L]
RewriteRule   ^index\.html$            netsw-home.cgi     [L]

#  strip out the subdirs when
#  the browser requests us from perdir pages
RewriteRule   ^.+/(netsw-[^/]+/.+)$    $1                 [L]

#  and now break the rewriting for local files
RewriteRule   ^netsw-home\.cgi.*       -                  [L]
RewriteRule   ^netsw-changes\.cgi.*    -                  [L]
RewriteRule   ^netsw-search\.cgi.*     -                  [L]
RewriteRule   ^netsw-tree\.cgi$        -                  [L]
RewriteRule   ^netsw-about\.html$      -                  [L]
RewriteRule   ^netsw-img/.*$           -                  [L]

#  anything else is a subdir which gets handled
#  by another cgi script
RewriteRule   !^netsw-lsdir\.cgi.*     -                  [C]
RewriteRule   (.*)                     netsw-lsdir.cgi/$1

Some hints for interpretation:

  1. Notice the L (last) flag and no substitution field ('-') in the forth part
  2. Notice the ! (not) character and the C (chain) flag at the first rule in the last part
  3. Notice the catch-all pattern in the last rule

NCSA imagemap to Apache mod_imagemap

Description:

When switching from the NCSA webserver to the more modern Apache webserver a lot of people want a smooth transition. So they want pages which use their old NCSA imagemap program to work under Apache with the modern mod_imagemap. The problem is that there are a lot of hyperlinks around which reference the imagemap program via /cgi-bin/imagemap/path/to/page.map. Under Apache this has to read just /path/to/page.map.

Solution:

We use a global rule to remove the prefix on-the-fly for all requests:

RewriteEngine  on
RewriteRule    ^/cgi-bin/imagemap(.*)  $1  [PT]

Search pages in more than one directory

Description:

Sometimes it is necessary to let the webserver search for pages in more than one directory. Here MultiViews or other techniques cannot help.

Solution:

We program a explicit ruleset which searches for the files in the directories.

RewriteEngine on

#   first try to find it in custom/...
#   ...and if found stop and be happy:
RewriteCond         /your/docroot/dir1/%{REQUEST_FILENAME}  -f
RewriteRule  ^(.+)  /your/docroot/dir1/$1  [L]

#   second try to find it in pub/...
#   ...and if found stop and be happy:
RewriteCond         /your/docroot/dir2/%{REQUEST_FILENAME}  -f
RewriteRule  ^(.+)  /your/docroot/dir2/$1  [L]

#   else go on for other Alias or ScriptAlias directives,
#   etc.
RewriteRule   ^(.+)  -  [PT]

Set Environment Variables According To URL Parts

Description:

Perhaps you want to keep status information between requests and use the URL to encode it. But you don't want to use a CGI wrapper for all pages just to strip out this information.

Solution:

We use a rewrite rule to strip out the status information and remember it via an environment variable which can be later dereferenced from within XSSI or CGI. This way a URL /foo/S=java/bar/ gets translated to /foo/bar/ and the environment variable named STATUS is set to the value "java".

RewriteEngine on
RewriteRule   ^(.*)/S=([^/]+)/(.*)    $1/$3 [E=STATUS:$2]

Virtual User Hosts

Description:

Assume that you want to provide www.username.host.domain.com for the homepage of username via just DNS A records to the same machine and without any virtualhosts on this machine.

Solution:

For HTTP/1.0 requests there is no solution, but for HTTP/1.1 requests which contain a Host: HTTP header we can use the following ruleset to rewrite http://www.username.host.com/anypath internally to /home/username/anypath:

RewriteEngine on
RewriteCond   %{HTTP_HOST}                 ^www\.[^.]+\.host\.com$
RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
RewriteRule   ^www\.([^.]+)\.host\.com(.*) /home/$1$2

Redirect Homedirs For Foreigners

Description:

We want to redirect homedir URLs to another webserver www.somewhere.com when the requesting user does not stay in the local domain ourdomain.com. This is sometimes used in virtual host contexts.

Solution:

Just a rewrite condition:

RewriteEngine on
RewriteCond   %{REMOTE_HOST}  !^.+\.ourdomain\.com$
RewriteRule   ^(/~.+)         http://www.somewhere.com/$1 [R,L]

Redirect Failing URLs To Other Webserver

Description:

A typical FAQ about URL rewriting is how to redirect failing requests on webserver A to webserver B. Usually this is done via ErrorDocument CGI-scripts in Perl, but there is also a mod_rewrite solution. But notice that this performs more poorly than using an ErrorDocument CGI-script!

Solution:

The first solution has the best performance but less flexibility, and is less error safe:

RewriteEngine on
RewriteCond   /your/docroot/%{REQUEST_FILENAME} !-f
RewriteRule   ^(.+)                             http://webserverB.dom/$1

The problem here is that this will only work for pages inside the DocumentRoot. While you can add more Conditions (for instance to also handle homedirs, etc.) there is better variant:

RewriteEngine on
RewriteCond   %{REQUEST_URI} !-U
RewriteRule   ^(.+)          http://webserverB.dom/$1

This uses the URL look-ahead feature of mod_rewrite. The result is that this will work for all types of URLs and is a safe way. But it does a performance impact on the webserver, because for every request there is one more internal subrequest. So, if your webserver runs on a powerful CPU, use this one. If it is a slow machine, use the first approach or better a ErrorDocument CGI-script.

Extended Redirection

Description:

Sometimes we need more control (concerning the character escaping mechanism) of URLs on redirects. Usually the Apache kernels URL escape function also escapes anchors, i.e. URLs like "url#anchor". You cannot use this directly on redirects with mod_rewrite because the uri_escape() function of Apache would also escape the hash character. How can we redirect to such a URL?

Solution:

We have to use a kludge by the use of a NPH-CGI script which does the redirect itself. Because here no escaping is done (NPH=non-parseable headers). First we introduce a new URL scheme xredirect: by the following per-server config-line (should be one of the last rewrite rules):

RewriteRule ^xredirect:(.+) /path/to/nph-xredirect.cgi/$1 \
            [T=application/x-httpd-cgi,L]

This forces all URLs prefixed with xredirect: to be piped through the nph-xredirect.cgi program. And this program just looks like:

#!/path/to/perl
##
##  nph-xredirect.cgi -- NPH/CGI script for extended redirects
##  Copyright (c) 1997 Ralf S. Engelschall, All Rights Reserved.
##

$| = 1;
$url = $ENV{'PATH_INFO'};

print "HTTP/1.0 302 Moved Temporarily\n";
print "Server: $ENV{'SERVER_SOFTWARE'}\n";
print "Location: $url\n";
print "Content-type: text/html\n";
print "\n";
print "<html>\n";
print "<head>\n";
print "<title>302 Moved Temporarily (EXTENDED)</title>\n";
print "</head>\n";
print "<body>\n";
print "<h1>Moved Temporarily (EXTENDED)</h1>\n";
print "The document has moved <a HREF=\"$url\">here</a>.<p>\n";
print "</body>\n";
print "</html>\n";

##EOF##

This provides you with the functionality to do redirects to all URL schemes, i.e. including the one which are not directly accepted by mod_rewrite. For instance you can now also redirect to news:newsgroup via

RewriteRule ^anyurl  xredirect:news:newsgroup
Notice: You have not to put [R] or [R,L] to the above rule because the xredirect: need to be expanded later by our special "pipe through" rule above.

Archive Access Multiplexer

Description:

Do you know the great CPAN (Comprehensive Perl Archive Network) under http://www.perl.com/CPAN? This does a redirect to one of several FTP servers around the world which carry a CPAN mirror and is approximately near the location of the requesting client. Actually this can be called an FTP access multiplexing service. While CPAN runs via CGI scripts, how can a similar approach implemented via mod_rewrite?

Solution:

First we notice that from version 3.0.0 mod_rewrite can also use the "ftp:" scheme on redirects. And second, the location approximation can be done by a RewriteMap over the top-level domain of the client. With a tricky chained ruleset we can use this top-level domain as a key to our multiplexing map.

RewriteEngine on
RewriteMap    multiplex                txt:/path/to/map.cxan
RewriteRule   ^/CxAN/(.*)              %{REMOTE_HOST}::$1                 [C]
RewriteRule   ^.+\.([a-zA-Z]+)::(.*)$  ${multiplex:$1|ftp.default.dom}$2  [R,L]
##
##  map.cxan -- Multiplexing Map for CxAN
##

de        ftp://ftp.cxan.de/CxAN/
uk        ftp://ftp.cxan.uk/CxAN/
com       ftp://ftp.cxan.com/CxAN/
 :
##EOF##

Time-Dependent Rewriting

Description:

When tricks like time-dependent content should happen a lot of webmasters still use CGI scripts which do for instance redirects to specialized pages. How can it be done via mod_rewrite?

Solution:

There are a lot of variables named TIME_xxx for rewrite conditions. In conjunction with the special lexicographic comparison patterns <STRING, >STRING and =STRING we can do time-dependent redirects:

RewriteEngine on
RewriteCond   %{TIME_HOUR}%{TIME_MIN} >0700
RewriteCond   %{TIME_HOUR}%{TIME_MIN} <1900
RewriteRule   ^foo\.html$             foo.day.html
RewriteRule   ^foo\.html$             foo.night.html

This provides the content of foo.day.html under the URL foo.html from 07:00-19:00 and at the remaining time the contents of foo.night.html. Just a nice feature for a homepage...

Backward Compatibility for YYYY to XXXX migration

Description:

How can we make URLs backward compatible (still existing virtually) after migrating document.YYYY to document.XXXX, e.g. after translating a bunch of .html files to .phtml?

Solution:

We just rewrite the name to its basename and test for existence of the new extension. If it exists, we take that name, else we rewrite the URL to its original state.

#   backward compatibility ruleset for
#   rewriting document.html to document.phtml
#   when and only when document.phtml exists
#   but no longer document.html
RewriteEngine on
RewriteBase   /~quux/
#   parse out basename, but remember the fact
RewriteRule   ^(.*)\.html$              $1      [C,E=WasHTML:yes]
#   rewrite to document.phtml if exists
RewriteCond   %{REQUEST_FILENAME}.phtml -f
RewriteRule   ^(.*)$ $1.phtml                   [S=1]
#   else reverse the previous basename cutout
RewriteCond   %{ENV:WasHTML}            ^yes$
RewriteRule   ^(.*)$ $1.html
top

Content Handling

From Old to New (intern)

Description:

Assume we have recently renamed the page foo.html to bar.html and now want to provide the old URL for backward compatibility. Actually we want that users of the old URL even not recognize that the pages was renamed.

Solution:

We rewrite the old URL to the new one internally via the following rule:

RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^foo\.html$  bar.html

From Old to New (extern)

Description:

Assume again that we have recently renamed the page foo.html to bar.html and now want to provide the old URL for backward compatibility. But this time we want that the users of the old URL get hinted to the new one, i.e. their browsers Location field should change, too.

Solution:

We force a HTTP redirect to the new URL which leads to a change of the browsers and thus the users view:

RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^foo\.html$  bar.html  [R]

Browser Dependent Content

Description:

At least for important top-level pages it is sometimes necessary to provide the optimum of browser dependent content, i.e. one has to provide a maximum version for the latest Netscape variants, a minimum version for the Lynx browsers and a average feature version for all others.

Solution:

We cannot use content negotiation because the browsers do not provide their type in that form. Instead we have to act on the HTTP header "User-Agent". The following condig does the following: If the HTTP header "User-Agent" begins with "Mozilla/3", the page foo.html is rewritten to foo.NS.html and and the rewriting stops. If the browser is "Lynx" or "Mozilla" of version 1 or 2 the URL becomes foo.20.html. All other browsers receive page foo.32.html. This is done by the following ruleset:

RewriteCond %{HTTP_USER_AGENT}  ^Mozilla/3.*
RewriteRule ^foo\.html$         foo.NS.html          [L]

RewriteCond %{HTTP_USER_AGENT}  ^Lynx/.*         [OR]
RewriteCond %{HTTP_USER_AGENT}  ^Mozilla/[12].*
RewriteRule ^foo\.html$         foo.20.html          [L]

RewriteRule ^foo\.html$         foo.32.html          [L]

Dynamic Mirror

Description:

Assume there are nice webpages on remote hosts we want to bring into our namespace. For FTP servers we would use the mirror program which actually maintains an explicit up-to-date copy of the remote data on the local machine. For a webserver we could use the program webcopy which acts similar via HTTP. But both techniques have one major drawback: The local copy is always just as up-to-date as often we run the program. It would be much better if the mirror is not a static one we have to establish explicitly. Instead we want a dynamic mirror with data which gets updated automatically when there is need (updated data on the remote host).

Solution:

To provide this feature we map the remote webpage or even the complete remote webarea to our namespace by the use of the Proxy Throughput feature (flag [P]):

RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^hotsheet/(.*)$  http://www.tstimpreso.com/hotsheet/$1  [P]
RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^usa-news\.html$   http://www.quux-corp.com/news/index.html  [P]

Reverse Dynamic Mirror

Description:
...
Solution:
RewriteEngine on
RewriteCond   /mirror/of/remotesite/$1           -U
RewriteRule   ^http://www\.remotesite\.com/(.*)$ /mirror/of/remotesite/$1

Retrieve Missing Data from Intranet

Description:

This is a tricky way of virtually running a corporate (external) Internet webserver (www.quux-corp.dom), while actually keeping and maintaining its data on a (internal) Intranet webserver (www2.quux-corp.dom) which is protected by a firewall. The trick is that on the external webserver we retrieve the requested data on-the-fly from the internal one.

Solution:

First, we have to make sure that our firewall still protects the internal webserver and that only the external webserver is allowed to retrieve data from it. For a packet-filtering firewall we could for instance configure a firewall ruleset like the following:

ALLOW Host www.quux-corp.dom Port >1024 --> Host www2.quux-corp.dom Port 80
DENY  Host *                 Port *     --> Host www2.quux-corp.dom Port 80

Just adjust it to your actual configuration syntax. Now we can establish the mod_rewrite rules which request the missing data in the background through the proxy throughput feature:

RewriteRule ^/~([^/]+)/?(.*)          /home/$1/.www/$2
RewriteCond %{REQUEST_FILENAME}       !-f
RewriteCond %{REQUEST_FILENAME}       !-d
RewriteRule ^/home/([^/]+)/.www/?(.*) http://www2.quux-corp.dom/~$1/pub/$2 [P]

Load Balancing

Description:

Suppose we want to load balance the traffic to www.foo.com over www[0-5].foo.com (a total of 6 servers). How can this be done?

Solution:

There are a lot of possible solutions for this problem. We will discuss first a commonly known DNS-based variant and then the special one with mod_rewrite:

  1. DNS Round-Robin

    The simplest method for load-balancing is to use the DNS round-robin feature of BIND. Here you just configure www[0-9].foo.com as usual in your DNS with A(address) records, e.g.

    www0   IN  A       1.2.3.1
    www1   IN  A       1.2.3.2
    www2   IN  A       1.2.3.3
    www3   IN  A       1.2.3.4
    www4   IN  A       1.2.3.5
    www5   IN  A       1.2.3.6
    

    Then you additionally add the following entry:

    www   IN  A       1.2.3.1
    www   IN  A       1.2.3.2
    www   IN  A       1.2.3.3
    www   IN  A       1.2.3.4
    www   IN  A       1.2.3.5
    

    Now when www.foo.com gets resolved, BIND gives out www0-www5 - but in a slightly permutated/rotated order every time. This way the clients are spread over the various servers. But notice that this not a perfect load balancing scheme, because DNS resolve information gets cached by the other nameservers on the net, so once a client has resolved www.foo.com to a particular wwwN.foo.com, all subsequent requests also go to this particular name wwwN.foo.com. But the final result is ok, because the total sum of the requests are really spread over the various webservers.

  2. DNS Load-Balancing

    A sophisticated DNS-based method for load-balancing is to use the program lbnamed which can be found at http://www.stanford.edu/~schemers/docs/lbnamed/lbnamed.html. It is a Perl 5 program in conjunction with auxilliary tools which provides a real load-balancing for DNS.

  3. Proxy Throughput Round-Robin

    In this variant we use mod_rewrite and its proxy throughput feature. First we dedicate www0.foo.com to be actually www.foo.com by using a single

    www    IN  CNAME   www0.foo.com.
    

    entry in the DNS. Then we convert www0.foo.com to a proxy-only server, i.e. we configure this machine so all arriving URLs are just pushed through the internal proxy to one of the 5 other servers (www1-www5). To accomplish this we first establish a ruleset which contacts a load balancing script lb.pl for all URLs.

    RewriteEngine on
    RewriteMap    lb      prg:/path/to/lb.pl
    RewriteRule   ^/(.+)$ ${lb:$1}           [P,L]
    

    Then we write lb.pl:

    #!/path/to/perl
    ##
    ##  lb.pl -- load balancing script
    ##
    
    $| = 1;
    
    $name   = "www";     # the hostname base
    $first  = 1;         # the first server (not 0 here, because 0 is myself)
    $last   = 5;         # the last server in the round-robin
    $domain = "foo.dom"; # the domainname
    
    $cnt = 0;
    while (<STDIN>) {
        $cnt = (($cnt+1) % ($last+1-$first));
        $server = sprintf("%s%d.%s", $name, $cnt+$first, $domain);
        print "http://$server/$_";
    }
    
    ##EOF##
    
    A last notice: Why is this useful? Seems like www0.foo.com still is overloaded? The answer is yes, it is overloaded, but with plain proxy throughput requests, only! All SSI, CGI, ePerl, etc. processing is completely done on the other machines. This is the essential point.
  4. Hardware/TCP Round-Robin

    There is a hardware solution available, too. Cisco has a beast called LocalDirector which does a load balancing at the TCP/IP level. Actually this is some sort of a circuit level gateway in front of a webcluster. If you have enough money and really need a solution with high performance, use this one.

New MIME-type, New Service

Description:

On the net there are a lot of nifty CGI programs. But their usage is usually boring, so a lot of webmaster don't use them. Even Apache's Action handler feature for MIME-types is only appropriate when the CGI programs don't need special URLs (actually PATH_INFO and QUERY_STRINGS) as their input. First, let us configure a new file type with extension .scgi (for secure CGI) which will be processed by the popular cgiwrap program. The problem here is that for instance we use a Homogeneous URL Layout (see above) a file inside the user homedirs has the URL /u/user/foo/bar.scgi. But cgiwrap needs the URL in the form /~user/foo/bar.scgi/. The following rule solves the problem:

RewriteRule ^/[uge]/([^/]+)/\.www/(.+)\.scgi(.*) ...
... /internal/cgi/user/cgiwrap/~$1/$2.scgi$3  [NS,T=application/x-http-cgi]

Or assume we have some more nifty programs: wwwlog (which displays the access.log for a URL subtree and wwwidx (which runs Glimpse on a URL subtree). We have to provide the URL area to these programs so they know on which area they have to act on. But usually this ugly, because they are all the times still requested from that areas, i.e. typically we would run the swwidx program from within /u/user/foo/ via hyperlink to

/internal/cgi/user/swwidx?i=/u/user/foo/

which is ugly. Because we have to hard-code both the location of the area and the location of the CGI inside the hyperlink. When we have to reorganize the area, we spend a lot of time changing the various hyperlinks.

Solution:

The solution here is to provide a special new URL format which automatically leads to the proper CGI invocation. We configure the following:

RewriteRule   ^/([uge])/([^/]+)(/?.*)/\*  /internal/cgi/user/wwwidx?i=/$1/$2$3/
RewriteRule   ^/([uge])/([^/]+)(/?.*):log /internal/cgi/user/wwwlog?f=/$1/$2$3

Now the hyperlink to search at /u/user/foo/ reads only

HREF="*"

which internally gets automatically transformed to

/internal/cgi/user/wwwidx?i=/u/user/foo/

The same approach leads to an invocation for the access log CGI program when the hyperlink :log gets used.

From Static to Dynamic

Description:

How can we transform a static page foo.html into a dynamic variant foo.cgi in a seamless way, i.e. without notice by the browser/user.

Solution:

We just rewrite the URL to the CGI-script and force the correct MIME-type so it gets really run as a CGI-script. This way a request to /~quux/foo.html internally leads to the invocation of /~quux/foo.cgi.

RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^foo\.html$  foo.cgi  [T=application/x-httpd-cgi]

On-the-fly Content-Regeneration

Description:

Here comes a really esoteric feature: Dynamically generated but statically served pages, i.e. pages should be delivered as pure static pages (read from the filesystem and just passed through), but they have to be generated dynamically by the webserver if missing. This way you can have CGI-generated pages which are statically served unless one (or a cronjob) removes the static contents. Then the contents gets refreshed.

Solution:
This is done via the following ruleset:
RewriteCond %{REQUEST_FILENAME}   !-s
RewriteRule ^page\.html$          page.cgi   [T=application/x-httpd-cgi,L]

Here a request to page.html leads to a internal run of a corresponding page.cgi if page.html is still missing or has filesize null. The trick here is that page.cgi is a usual CGI script which (additionally to its STDOUT) writes its output to the file page.html. Once it was run, the server sends out the data of page.html. When the webmaster wants to force a refresh the contents, he just removes page.html (usually done by a cronjob).

Document With Autorefresh

Description:

Wouldn't it be nice while creating a complex webpage if the webbrowser would automatically refresh the page every time we write a new version from within our editor? Impossible?

Solution:

No! We just combine the MIME multipart feature, the webserver NPH feature and the URL manipulation power of mod_rewrite. First, we establish a new URL feature: Adding just :refresh to any URL causes this to be refreshed every time it gets updated on the filesystem.

RewriteRule   ^(/[uge]/[^/]+/?.*):refresh  /internal/cgi/apache/nph-refresh?f=$1

Now when we reference the URL

/u/foo/bar/page.html:refresh

this leads to the internal invocation of the URL

/internal/cgi/apache/nph-refresh?f=/u/foo/bar/page.html

The only missing part is the NPH-CGI script. Although one would usually say "left as an exercise to the reader" ;-) I will provide this, too.

#!/sw/bin/perl
##
##  nph-refresh -- NPH/CGI script for auto refreshing pages
##  Copyright (c) 1997 Ralf S. Engelschall, All Rights Reserved.
##
$| = 1;

#   split the QUERY_STRING variable
@pairs = split(/&/, $ENV{'QUERY_STRING'});
foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $name =~ tr/A-Z/a-z/;
    $name = 'QS_' . $name;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    eval "\$$name = \"$value\"";
}
$QS_s = 1 if ($QS_s eq '');
$QS_n = 3600 if ($QS_n eq '');
if ($QS_f eq '') {
    print "HTTP/1.0 200 OK\n";
    print "Content-type: text/html\n\n";
    print "&lt;b&gt;ERROR&lt;/b&gt;: No file given\n";
    exit(0);
}
if (! -f $QS_f) {
    print "HTTP/1.0 200 OK\n";
    print "Content-type: text/html\n\n";
    print "&lt;b&gt;ERROR&lt;/b&gt;: File $QS_f not found\n";
    exit(0);
}

sub print_http_headers_multipart_begin {
    print "HTTP/1.0 200 OK\n";
    $bound = "ThisRandomString12345";
    print "Content-type: multipart/x-mixed-replace;boundary=$bound\n";
    &print_http_headers_multipart_next;
}

sub print_http_headers_multipart_next {
    print "\n--$bound\n";
}

sub print_http_headers_multipart_end {
    print "\n--$bound--\n";
}

sub displayhtml {
    local($buffer) = @_;
    $len = length($buffer);
    print "Content-type: text/html\n";
    print "Content-length: $len\n\n";
    print $buffer;
}

sub readfile {
    local($file) = @_;
    local(*FP, $size, $buffer, $bytes);
    ($x, $x, $x, $x, $x, $x, $x, $size) = stat($file);
    $size = sprintf("%d", $size);
    open(FP, "&lt;$file");
    $bytes = sysread(FP, $buffer, $size);
    close(FP);
    return $buffer;
}

$buffer = &readfile($QS_f);
&print_http_headers_multipart_begin;
&displayhtml($buffer);

sub mystat {
    local($file) = $_[0];
    local($time);

    ($x, $x, $x, $x, $x, $x, $x, $x, $x, $mtime) = stat($file);
    return $mtime;
}

$mtimeL = &mystat($QS_f);
$mtime = $mtime;
for ($n = 0; $n &lt; $QS_n; $n++) {
    while (1) {
        $mtime = &mystat($QS_f);
        if ($mtime ne $mtimeL) {
            $mtimeL = $mtime;
            sleep(2);
            $buffer = &readfile($QS_f);
            &print_http_headers_multipart_next;
            &displayhtml($buffer);
            sleep(5);
            $mtimeL = &mystat($QS_f);
            last;
        }
        sleep($QS_s);
    }
}

&print_http_headers_multipart_end;

exit(0);

##EOF##

Mass Virtual Hosting

Description:

The <VirtualHost> feature of Apache is nice and works great when you just have a few dozens virtual hosts. But when you are an ISP and have hundreds of virtual hosts to provide this feature is not the best choice.

Solution:

To provide this feature we map the remote webpage or even the complete remote webarea to our namespace by the use of the Proxy Throughput feature (flag [P]):

##
##  vhost.map
##
www.vhost1.dom:80  /path/to/docroot/vhost1
www.vhost2.dom:80  /path/to/docroot/vhost2
     :
www.vhostN.dom:80  /path/to/docroot/vhostN
##
##  httpd.conf
##
    :
#   use the canonical hostname on redirects, etc.
UseCanonicalName on

    :
#   add the virtual host in front of the CLF-format
CustomLog  /path/to/access_log  "%{VHOST}e %h %l %u %t \"%r\" %>s %b"
    :

#   enable the rewriting engine in the main server
RewriteEngine on

#   define two maps: one for fixing the URL and one which defines
#   the available virtual hosts with their corresponding
#   DocumentRoot.
RewriteMap    lowercase    int:tolower
RewriteMap    vhost        txt:/path/to/vhost.map

#   Now do the actual virtual host mapping
#   via a huge and complicated single rule:
#
#   1. make sure we don't map for common locations
RewriteCond   %{REQUEST_URI}  !^/commonurl1/.*
RewriteCond   %{REQUEST_URI}  !^/commonurl2/.*
    :
RewriteCond   %{REQUEST_URI}  !^/commonurlN/.*
#
#   2. make sure we have a Host header, because
#      currently our approach only supports
#      virtual hosting through this header
RewriteCond   %{HTTP_HOST}  !^$
#
#   3. lowercase the hostname
RewriteCond   ${lowercase:%{HTTP_HOST}|NONE}  ^(.+)$
#
#   4. lookup this hostname in vhost.map and
#      remember it only when it is a path
#      (and not "NONE" from above)
RewriteCond   ${vhost:%1}  ^(/.*)$
#
#   5. finally we can map the URL to its docroot location
#      and remember the virtual host for logging puposes
RewriteRule   ^/(.*)$   %1/$1  [E=VHOST:${lowercase:%{HTTP_HOST}}]
    :
top

Access Restriction

Blocking of Robots

Description:

How can we block a really annoying robot from retrieving pages of a specific webarea? A /robots.txt file containing entries of the "Robot Exclusion Protocol" is typically not enough to get rid of such a robot.

Solution:

We use a ruleset which forbids the URLs of the webarea /~quux/foo/arc/ (perhaps a very deep directory indexed area where the robot traversal would create big server load). We have to make sure that we forbid access only to the particular robot, i.e. just forbidding the host where the robot runs is not enough. This would block users from this host, too. We accomplish this by also matching the User-Agent HTTP header information.

RewriteCond %{HTTP_USER_AGENT}   ^NameOfBadRobot.*
RewriteCond %{REMOTE_ADDR}       ^123\.45\.67\.[8-9]$
RewriteRule ^/~quux/foo/arc/.+   -   [F]

Blocked Inline-Images

Description:

Assume we have under http://www.quux-corp.de/~quux/ some pages with inlined GIF graphics. These graphics are nice, so others directly incorporate them via hyperlinks to their pages. We don't like this practice because it adds useless traffic to our server.

Solution:

While we cannot 100% protect the images from inclusion, we can at least restrict the cases where the browser sends a HTTP Referer header.

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www.quux-corp.de/~quux/.*$ [NC]
RewriteRule .*\.gif$        -                                    [F]
RewriteCond %{HTTP_REFERER}         !^$
RewriteCond %{HTTP_REFERER}         !.*/foo-with-gif\.html$
RewriteRule ^inlined-in-foo\.gif$   -                        [F]

Host Deny

Description:

How can we forbid a list of externally configured hosts from using our server?

Solution:

For Apache >= 1.3b6:

RewriteEngine on
RewriteMap    hosts-deny  txt:/path/to/hosts.deny
RewriteCond   ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND [OR]
RewriteCond   ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND
RewriteRule   ^/.*  -  [F]

For Apache <= 1.3b6:

RewriteEngine on
RewriteMap    hosts-deny  txt:/path/to/hosts.deny
RewriteRule   ^/(.*)$ ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND}/$1
RewriteRule   !^NOT-FOUND/.* - [F]
RewriteRule   ^NOT-FOUND/(.*)$ ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND}/$1
RewriteRule   !^NOT-FOUND/.* - [F]
RewriteRule   ^NOT-FOUND/(.*)$ /$1
##
##  hosts.deny
##
##  ATTENTION! This is a map, not a list, even when we treat it as such.
##             mod_rewrite parses it for key/value pairs, so at least a
##             dummy value "-" must be present for each entry.
##

193.102.180.41 -
bsdti1.sdm.de  -
192.76.162.40  -

Proxy Deny

Description:

How can we forbid a certain host or even a user of a special host from using the Apache proxy?

Solution:

We first have to make sure mod_rewrite is below(!) mod_proxy in the Configuration file when compiling the Apache webserver. This way it gets called before mod_proxy. Then we configure the following for a host-dependent deny...

RewriteCond %{REMOTE_HOST} ^badhost\.mydomain\.com$
RewriteRule !^http://[^/.]\.mydomain.com.*  - [F]

...and this one for a user@host-dependent deny:

RewriteCond %{REMOTE_IDENT}@%{REMOTE_HOST}  ^badguy@badhost\.mydomain\.com$
RewriteRule !^http://[^/.]\.mydomain.com.*  - [F]

Special Authentication Variant

Description:

Sometimes a very special authentication is needed, for instance a authentication which checks for a set of explicitly configured users. Only these should receive access and without explicit prompting (which would occur when using the Basic Auth via mod_auth_basic).

Solution:

We use a list of rewrite conditions to exclude all except our friends:

RewriteCond %{REMOTE_IDENT}@%{REMOTE_HOST} !^friend1@client1.quux-corp\.com$
RewriteCond %{REMOTE_IDENT}@%{REMOTE_HOST} !^friend2@client2.quux-corp\.com$
RewriteCond %{REMOTE_IDENT}@%{REMOTE_HOST} !^friend3@client3.quux-corp\.com$
RewriteRule ^/~quux/only-for-friends/      -                                 [F]

Referer-based Deflector

Description:

How can we program a flexible URL Deflector which acts on the "Referer" HTTP header and can be configured with as many referring pages as we like?

Solution:

Use the following really tricky ruleset...

RewriteMap  deflector txt:/path/to/deflector.map

RewriteCond %{HTTP_REFERER} !=""
RewriteCond ${deflector:%{HTTP_REFERER}} ^-$
RewriteRule ^.* %{HTTP_REFERER} [R,L]

RewriteCond %{HTTP_REFERER} !=""
RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND
RewriteRule ^.* ${deflector:%{HTTP_REFERER}} [R,L]

... in conjunction with a corresponding rewrite map:

##
##  deflector.map
##

http://www.badguys.com/bad/index.html    -
http://www.badguys.com/bad/index2.html   -
http://www.badguys.com/bad/index3.html   http://somewhere.com/

This automatically redirects the request back to the referring page (when "-" is used as the value in the map) or to a specific URL (when an URL is specified in the map as the second argument).

top

Other

External Rewriting Engine

Description:

A FAQ: How can we solve the FOO/BAR/QUUX/etc. problem? There seems no solution by the use of mod_rewrite...

Solution:

Use an external RewriteMap, i.e. a program which acts like a RewriteMap. It is run once on startup of Apache receives the requested URLs on STDIN and has to put the resulting (usually rewritten) URL on STDOUT (same order!).

RewriteEngine on
RewriteMap    quux-map       prg:/path/to/map.quux.pl
RewriteRule   ^/~quux/(.*)$  /~quux/${quux-map:$1}
#!/path/to/perl

#   disable buffered I/O which would lead
#   to deadloops for the Apache server
$| = 1;

#   read URLs one per line from stdin and
#   generate substitution URL on stdout
while (<>) {
    s|^foo/|bar/|;
    print $_;
}

This is a demonstration-only example and just rewrites all URLs /~quux/foo/... to /~quux/bar/.... Actually you can program whatever you like. But notice that while such maps can be used also by an average user, only the system administrator can define it.

misc/security_tips.html100644 0 0 42040 11237400230 12744 0ustar 0 0 Security Tips - Apache HTTP Server
<-

Security Tips

Some hints and tips on security issues in setting up a web server. Some of the suggestions will be general, others specific to Apache.

top

Keep up to Date

The Apache HTTP Server has a good record for security and a developer community highly concerned about security issues. But it is inevitable that some problems -- small or large -- will be discovered in software after it is released. For this reason, it is crucial to keep aware of updates to the software. If you have obtained your version of the HTTP Server directly from Apache, we highly recommend you subscribe to the Apache HTTP Server Announcements List where you can keep informed of new releases and security updates. Similar services are available from most third-party distributors of Apache software.

Of course, most times that a web server is compromised, it is not because of problems in the HTTP Server code. Rather, it comes from problems in add-on code, CGI scripts, or the underlying Operating System. You must therefore stay aware of problems and updates with all the software on your system.

top

Permissions on ServerRoot Directories

In typical operation, Apache is started by the root user, and it switches to the user defined by the User directive to serve hits. As is the case with any command that root executes, you must take care that it is protected from modification by non-root users. Not only must the files themselves be writeable only by root, but so must the directories, and parents of all directories. For example, if you choose to place ServerRoot in /usr/local/apache then it is suggested that you create that directory as root, with commands like these:

mkdir /usr/local/apache
cd /usr/local/apache
mkdir bin conf logs
chown 0 . bin conf logs
chgrp 0 . bin conf logs
chmod 755 . bin conf logs

It is assumed that /, /usr, and /usr/local are only modifiable by root. When you install the httpd executable, you should ensure that it is similarly protected:

cp httpd /usr/local/apache/bin
chown 0 /usr/local/apache/bin/httpd
chgrp 0 /usr/local/apache/bin/httpd
chmod 511 /usr/local/apache/bin/httpd

You can create an htdocs subdirectory which is modifiable by other users -- since root never executes any files out of there, and shouldn't be creating files in there.

If you allow non-root users to modify any files that root either executes or writes on then you open your system to root compromises. For example, someone could replace the httpd binary so that the next time you start it, it will execute some arbitrary code. If the logs directory is writeable (by a non-root user), someone could replace a log file with a symlink to some other system file, and then root might overwrite that file with arbitrary data. If the log files themselves are writeable (by a non-root user), then someone may be able to overwrite the log itself with bogus data.

top

Server Side Includes

Server Side Includes (SSI) present a server administrator with several potential security risks.

The first risk is the increased load on the server. All SSI-enabled files have to be parsed by Apache, whether or not there are any SSI directives included within the files. While this load increase is minor, in a shared server environment it can become significant.

SSI files also pose the same risks that are associated with CGI scripts in general. Using the exec cmd element, SSI-enabled files can execute any CGI script or program under the permissions of the user and group Apache runs as, as configured in httpd.conf.

There are ways to enhance the security of SSI files while still taking advantage of the benefits they provide.

To isolate the damage a wayward SSI file can cause, a server administrator can enable suexec as described in the CGI in General section.

Enabling SSI for files with .html or .htm extensions can be dangerous. This is especially true in a shared, or high traffic, server environment. SSI-enabled files should have a separate extension, such as the conventional .shtml. This helps keep server load at a minimum and allows for easier management of risk.

Another solution is to disable the ability to run scripts and programs from SSI pages. To do this replace Includes with IncludesNOEXEC in the Options directive. Note that users may still use <--#include virtual="..." --> to execute CGI scripts if these scripts are in directories designated by a ScriptAlias directive.

top

CGI in General

First of all, you always have to remember that you must trust the writers of the CGI scripts/programs or your ability to spot potential security holes in CGI, whether they were deliberate or accidental. CGI scripts can run essentially arbitrary commands on your system with the permissions of the web server user and can therefore be extremely dangerous if they are not carefully checked.

All the CGI scripts will run as the same user, so they have potential to conflict (accidentally or deliberately) with other scripts e.g. User A hates User B, so he writes a script to trash User B's CGI database. One program which can be used to allow scripts to run as different users is suEXEC which is included with Apache as of 1.2 and is called from special hooks in the Apache server code. Another popular way of doing this is with CGIWrap.

top

Non Script Aliased CGI

Allowing users to execute CGI scripts in any directory should only be considered if:

  • You trust your users not to write scripts which will deliberately or accidentally expose your system to an attack.
  • You consider security at your site to be so feeble in other areas, as to make one more potential hole irrelevant.
  • You have no users, and nobody ever visits your server.
top

Script Aliased CGI

Limiting CGI to special directories gives the admin control over what goes into those directories. This is inevitably more secure than non script aliased CGI, but only if users with write access to the directories are trusted or the admin is willing to test each new CGI script/program for potential security holes.

Most sites choose this option over the non script aliased CGI approach.

top

Other sources of dynamic content

Embedded scripting options which run as part of the server itself, such as mod_php, mod_perl, mod_tcl, and mod_python, run under the identity of the server itself (see the User directive), and therefore scripts executed by these engines potentially can access anything the server user can. Some scripting engines may provide restrictions, but it is better to be safe and assume not.

top

Protecting System Settings

To run a really tight ship, you'll want to stop users from setting up .htaccess files which can override security features you've configured. Here's one way to do it.

In the server configuration file, put

<Directory />
AllowOverride None
</Directory>

This prevents the use of .htaccess files in all directories apart from those specifically enabled.

top

Protect Server Files by Default

One aspect of Apache which is occasionally misunderstood is the feature of default access. That is, unless you take steps to change it, if the server can find its way to a file through normal URL mapping rules, it can serve it to clients.

For instance, consider the following example:

# cd /; ln -s / public_html
Accessing http://localhost/~root/

This would allow clients to walk through the entire filesystem. To work around this, add the following block to your server's configuration:

<Directory />
Order Deny,Allow
Deny from all
</Directory>

This will forbid default access to filesystem locations. Add appropriate Directory blocks to allow access only in those areas you wish. For example,

<Directory /usr/users/*/public_html>
Order Deny,Allow
Allow from all
</Directory>
<Directory /usr/local/httpd>
Order Deny,Allow
Allow from all
</Directory>

Pay particular attention to the interactions of Location and Directory directives; for instance, even if <Directory /> denies access, a <Location /> directive might overturn it.

Also be wary of playing games with the UserDir directive; setting it to something like ./ would have the same effect, for root, as the first example above. If you are using Apache 1.3 or above, we strongly recommend that you include the following line in your server configuration files:

UserDir disabled root

top

Watching Your Logs

To keep up-to-date with what is actually going on against your server you have to check the Log Files. Even though the log files only reports what has already happened, they will give you some understanding of what attacks is thrown against the server and allow you to check if the necessary level of security is present.

A couple of examples:

grep -c "/jsp/source.jsp?/jsp/ /jsp/source.jsp??" access_log
grep "client denied" error_log | tail -n 10

The first example will list the number of attacks trying to exploit the Apache Tomcat Source.JSP Malformed Request Information Disclosure Vulnerability, the second example will list the ten last denied clients, for example:

[Thu Jul 11 17:18:39 2002] [error] [client foo.example.com] client denied by server configuration: /usr/local/apache/htdocs/.htpasswd

As you can see, the log files only report what already has happened, so if the client had been able to access the .htpasswd file you would have seen something similar to:

foo.example.com - - [12/Jul/2002:01:59:13 +0200] "GET /.htpasswd HTTP/1.1"

in your Access Log. This means you probably commented out the following in your server configuration file:

<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>

mod/beos.html100644 0 0 14205 11237400230 10614 0ustar 0 0 beos - Apache HTTP Server
<-

Apache MPM beos

Description:This Multi-Processing Module is optimized for BeOS.
Status:MPM
ModuleIdentifier:mpm_beos_module
SourceFile:beos.c

Summary

This Multi-Processing Module (MPM) is the default for BeOS. It uses a single control process which creates threads to handle requests.

top

MaxRequestsPerThread Directive

Description:Limit on the number of requests that an individual thread will handle during its life
Syntax:MaxRequestsPerThread number
Default:MaxRequestsPerThread 0
Context:server config
Status:MPM
Module:beos

The MaxRequestsPerThread directive sets the limit on the number of requests that an individual server thread will handle. After MaxRequestsPerThread requests, the thread will die. If MaxRequestsPerThread is 0, then the thread will never expire.

Setting MaxRequestsPerThread to a non-zero limit has two beneficial effects:

  • it limits the amount of memory that a thread can consume by (accidental) memory leakage;
  • by giving threads a finite lifetime, it helps reduce the number of threads when the server load reduces.

Note:

For KeepAlive requests, only the first request is counted towards this limit. In effect, it changes the behavior to limit the number of connections per thread.

mod/core.html100644 0 0 661402 11237400230 10643 0ustar 0 0 core - Apache HTTP サーバ
<-

Apache コア機能

This translation may be out of date. Check the English version for recent changes.
説明:常に使用可能な Apache HTTP サーバのコア機能
ステータス:Core
top

AcceptFilter ディレクティブ

説明:プロトコルを Listen しているソケットの最適化を設定する
構文:AcceptFilter protocol accept_filter
コンテキスト:サーバ設定ファイル
ステータス:Core
モジュール:core
互換性:2.1.5 以降

Listen しているソケットに対して、OS が固有に持っているプロトコルについての最適化を 有効にするディレクティブです。大前提となる条件は、データが受信されるか HTTP リクエスト全体がバッファされるかするまで、カーネルがサーバプロセスに ソケットを送らないようになっている、ということです。現在サポートされているのは、 FreeBSD の Accept Filter と Linux のプリミティブな TCP_DEFER_ACCEPT のみです。

FreeBSD のデフォルト値は :

AcceptFilter http httpready
AcceptFilter https dataready

httpready Accept Filter は HTTP リクエスト全体を、 カーネルレベルでバッファリングします。リクエスト全体を受信し終わると、 その後サーバプロセスにそれを送ります。詳細については accf_http(9) を参照してください。HTTPS のリクエストは暗号化されているので accf_data(9) フィルタのみが使用されます。

Linux でのデフォルト値は :

AcceptFilter http data
AcceptFilter https data

Linux の TCP_DEFER_ACCEPT は HTTP リクエストのバッファリングを サポートしていません。none 以外の値で TCP_DEFER_ACCEPT が有効になります。詳細については Linux man ページ tcp(7) を参照してください。

引数に none を指定すると、プロトコルに対する全ての Accept Filter が無効になります。nntp といった、先にサーバにデータを 送る必要のあるプロトコルに有効です :

AcceptFilter nntp none

top

AcceptPathInfo ディレクティブ

説明:後に続くパス名情報を受け付けるリソースの指定
構文:AcceptPathInfo On|Off|Default
デフォルト:AcceptPathInfo Default
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Core
モジュール:core
互換性:Apache 2.0.30 以降で使用可能

このディレクティブは実際のファイル名 (もしくは存在するディレクトリの 存在しないファイル) の後に続くパス名情報があるリクエストを受け付けるか 拒否するかを制御します。続きのパス名情報はスクリプトには PATH_INFO 環境変数として利用可能になります。

例えば、/test/ が、here.html というファイル 一つのみがあるディレクトリを指しているとします。そうすると、 /test/here.html/more/test/nothere.html/more へのリクエストは両方とも /morePATH_INFO とします。

AcceptPathInfo ディレクティブに指定可能な 三つの引数は:

Off
リクエストは存在するパスにそのまま マップされる場合にのみ受け付けられます。ですから、上の例の /test/here.html/more のように、本当のファイル名の 後にパス名情報が続くリクエストには 404 NOT FOUND エラーが返ります。
On
前の方のパスが存在するファイルにマップする場合は リクエストが受け付けられます。上の例の /test/here.html/more/test/here.html が有効なファイルにマップすれば 受け付けられます。
Default
続きのパス名情報の扱いはリクエストの ハンドラで決まります。 普通のファイルのためのコアハンドラのデフォルトは PATH_INFO を拒否します。 cgi-scriptisapi-handler のようにスクリプトを扱うハンドラは 一般的にデフォルトで PATH_INFO を受け付けます。

AcceptPathInfo の主な目的はハンドラの PATH_INFO を 受け付けるか拒否するかの選択を上書きできるようにすることです。 例えば、これは例えば INCLUDES のような フィルタを使って PATH_INFO に 基づいてコンテンツを生成しているときに必要になります。

<Files "mypaths.shtml">
Options +Includes
SetOutputFilter INCLUDES
AcceptPathInfo On
</Files>

top

AccessFileName ディレクティブ

説明:分散設定ファイルの名前
構文:AccessFileName filename [filename] ...
デフォルト:AccessFileName .htaccess
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core

リクエストを処理するとき、サーバはディレクトリに 対して分散設定ファイルが有効になっていれば、 そのドキュメントへの パス上にある全てのディレクトリから、ここで指定された名前の一覧の中で 最初に見つかったファイルをそれぞれ設定ファイルとして読み込みます。例えば:

AccessFileName .acl

という設定があると、以下のようにして無効にされていない限り、 ドキュメント /usr/local/web/index.html を返す前に、サーバは /.acl, /usr/.acl, /usr/local/.acl, /usr/local/web/.acl から ディレクティブを読み込みます。

<Directory />
AllowOverride None
</Directory>

参照

top

AddDefaultCharset ディレクティブ

説明:レスポンスのコンテントタイプが text/plain あるいは text/html の場合に追加するデフォルトの charset パラメータ
構文:AddDefaultCharset On|Off|charset
デフォルト:AddDefaultCharset Off
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Core
モジュール:core

レスポンスのコンテントタイプが text/plain あるいは text/html の場合に限りますが、レスポンスに追加するメディアタイプの文字セットパラメータ (文字エンコーディングの名前) のデフォルト値を、このディレクティブで指定します。 これはレスポンス (訳注: レスポンスの HTML) 内で META 要素で指定された、どのような文字セットも無効にしますが、 最終的な挙動はユーザのクライアント側の設定で決まります。 この機能は AddDefaultCharset Off という設定で無効になります。 AddDefaultCharset On にすれば、 Apache 内部のデフォルト文字セット iso-8859-1 に設定されます。 その他 charset に指定できる値であれば、どんな値でも使えます。 指定する値は、MIME メディアタイプとして使われる IANA に登録されている文字セット名のうちの一つにすべきです。 例えば:

AddDefaultCharset utf-8

AddDefaultCharset を使うときは、全てのテキストリソースが 指定する文字エンコードになっていると分かっていて、かつ、 リソースの個々に文字セットを指定するのが大変な場合のみです。 例を挙げると、レガシーな CGI スクリプトなどの、動的に生成される コンテンツを含むリソースに文字セットパラメータを追加する場合で、 ユーザの入力データが出力に入り、クロスサイトスクリプティングが 引き起こされうる場合です。デフォルト文字セットをセットしたとしても、 ブラウザの "文字エンコードの自動選択" 機能が有効になっているユーザを 守ることにはならないので、もちろんより良い解決策は単にスクリプトを修正 (あるいは削除) することです。

参照

top

AddOutputFilterByType ディレクティブ

説明:MIME-type に出力フィルタを割り当てる
構文:AddOutputFilterByType filter[;filter...] MIME-type [MIME-type] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Core
モジュール:core
互換性:Apache 2.0.33 以降で使用可能。ただし 2.1 以降で非推奨。

このディレクティブは応答の MIME タイプ に応じて出力フィルタを使用するようにします。 ただし下で説明される理由により、本ディレクティブは非推奨です。 同等の機能は mod_filter で利用できます。

次の例は mod_deflateDEFLATE フィルタを 使っています。text/htmltext/plain の すべての出力 (静的なものも動的なものも) をクライアントに送られる前に 圧縮します。

AddOutputFilterByType DEFLATE text/html text/plain

複数のフィルタでコンテンツを処理させたいときは、それぞれの名前をセミコロンで 分ける必要があります。各フィルタに対して AddOutputFilterByType を一つずつ書くこともできます。

次の例は text/html のスクリプトのすべての出力を まず INCLUDES フィルタで処理し、さらに DEFLATE フィルタにかけます。

<Location /cgi-bin/>
Options Includes
AddOutputFilterByType INCLUDES;DEFLATE text/html
</Location>

注:

AddOutputFilterByType ディレクティブにより 有効にしたフィルタは場合によっては、部分的もしくは完全に適用されないことが あります。例えば、MIME タイプ が決定できないときには DefaultType の設定が同じだったとしても、 DefaultType 設定を使うようになります。

しかし、確実にフィルタが適用されるようにしたいときは、リソースに 明示的にコンテントタイプを割り当てることができます。これには例えば AddType ディレクティブや ForceType ディレクティブを使います。 (nphでない) CGI スクリプトでコンテントタイプを設定するというものでも 大丈夫です。

参照

top

AllowEncodedSlashes ディレクティブ

説明:URL 中の符号化されたパス分離文字が先に伝えられるのを許可するかどうかを 決定する
構文:AllowEncodedSlashes On|Off
デフォルト:AllowEncodedSlashes Off
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core
互換性:Apache 2.0.46 以降で使用可能

AllowEncodedSlashes ディレクティブは符号化された パス分離文字 (/%2F、さらにシステムによっては \ に対応する %5C) が存在する URL の使用を 許可するかどうかを決定します。通常はそのような URL は 404 (Not found) エラー で拒否されます。

AllowEncodedSlashes On による パス分離文字の使用は、PATH_INFO と合わせて 使うときに一番役に立ちます。

符号化されたスラッシュを許可することは、復号をすることを 意味しません%2F や (関係するシステムでの) %5C は、他の部分が復号された URL の中でもそのままの形式で 残されます。

参照

top

AllowOverride ディレクティブ

説明:.htaccess で許可されるディレクティブの種類
構文:AllowOverride All|None|directive-type [directive-type] ...
デフォルト:AllowOverride All
コンテキスト:ディレクトリ
ステータス:Core
モジュール:core

サーバが (AccessFileName によって指定された) .htaccess ファイルを見つけた時、そのファイルの中で 宣言されたどのディレクティブがより前に定義された設定ディレクティブを 上書きできるかを知る必要があります。

<Directory> セクションでのみ使用可能

AllowOverride は正規表現無しの<Directory> セクションでのみ有効で、<Location><DirectoryMatch><Files> セクションでは無効です。

このディレクティブを None に設定すると、.htaccess ファイルは完全に 無視されます。 この場合、サーバはファイルシステムの .htaccess ファイルを読むことを 試みさえしません。

このディレクティブが All に設定されている時には、 .htaccess という コンテキスト を持つ 全てのディレクティブが利用できます。

directive-type には、以下のディレクティブ群の キーワードのどれかを指定します。

AuthConfig
認証に関するディレクティブの使用を許可する (AuthDBMGroupFile, AuthDBMUserFile, AuthGroupFile, AuthName, AuthType, AuthUserFile, Require など)。
FileInfo
ドキュメントタイプを制御するディレクティブ (DefaultType, ErrorDocument, ForceType, LanguagePriority, SetHandler, SetInputFilter, SetOutputFilter, mod_mime の Add* と Remove* ディレクティブなど)、 ドキュメントのメタデータを制御するディレクティブ (Header, RequestHeader, SetEnvIf, SetEnvIfNoCase, BrowserMatch, CookieExpires, CookieDomain, CookieStyle, CookieTracking, CookieName), mod_rewrite のディレクティブ RewriteEngine, RewriteOptions, RewriteBase, RewriteCond, RewriteRule) と mod_actionsAction ディレクティブの使用を許可する。
Indexes
ディレクトリインデックスを制御するためのディレクティブの使用を許可する (AddDescription, AddIcon, AddIconByEncoding, AddIconByType, DefaultIcon, DirectoryIndex, FancyIndexing, HeaderName, IndexIgnore, IndexOptions, ReadmeName など)。
Limit
ホストへのアクセス制御を行うためのディレクティブの使用を許可する (Allow, Deny, Order).
Options[=Option,...]
特定のディレクトリにおける機能を指定するためのディレクティブの使用を許可する (OptionsXBitHack)。 Options で設定するオプション を、(空白を含めない) コンマ区切りのリストにして等号の後に続けることで 設定できます。

例:

AllowOverride AuthConfig Indexes

上の例では AuthConfigIndexes のどちらにも 属さないディレクティブはすべて内部サーバエラーを引き起こします。

参照

top

AuthName ディレクティブ

説明:HTTP 認証の認可領域 (訳注: realm)
構文:AuthName auth-domain
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Core
モジュール:core

このディレクティブはディレクトリに対する認可領域 (訳注: realm) の名前を指定します。 認可領域は、利用者がどのユーザ名とパスワードを送信すればよいのかを クライアントに教えるために利用します。 AuthName は一つの引数をとり、 スペースが含まれる場合には、 引用符で括らなければなりません。 このディレクティブは AuthType ディレクティブや Require ディレクティブと、 AuthUserFileAuthGroupFile などのディレクティブと 一緒に利用する必要があります。

例えば:

AuthName "Top Secret"

ここで AuthName に指定した文字列が、 大部分のブラウザのパスワードダイアログに表示されます。

参照

top

AuthType ディレクティブ

説明:ユーザ認証の種類
構文:AuthType Basic|Digest
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Core
モジュール:core

このディレクティブは対象ディレクトリで利用するユーザー認証の種類を選びます。 使用できる認証方式は Basic (mod_auth_basic で実装) と Digest (mod_auth_digest で実装) です。

認証を有効にするには、AuthNameRequire ディレクティブも 使う必要があります。それに加えて認証プロバイダモジュールの mod_authn_file 等と、承認モジュール mod_authz_user 等もサーバに組み込む必要があります。

参照

top

CGIMapExtension ディレクティブ

説明:CGI スクリプトのインタープリタの位置を調べるための手法
構文:CGIMapExtension cgi-path .extension
コンテキスト:ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Core
モジュール:core
互換性:NetWare のみ

このディレクティブは Apache が CGI スクリプトを実行するための インタープリタを探す方法を制御します。 例えば、CGIMapExtension sys:\foo.nlm .foo と設定すると .foo という拡張子のすべての CGI スクリプトは FOO インタープリタに 渡されます。

top

ContentDigest ディレクティブ

説明:Content-MD5 HTTP 応答ヘッダの生成を有効にする
構文:ContentDigest On|Off
デフォルト:ContentDigest Off
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Options
ステータス:Core
モジュール:core

このディレクティブは、RFC1864 及び RFC2616 において定義されている Content-MD5 ヘッダーの生成を有効にします。

MD5 は、任意長のデータの「メッセージダイジェスト」(「指紋」 と表現されることもある) を計算するアルゴリズムで、 データの変更があった場合には非常に高い信頼度でメッセージダイジェストに変更が 反映されます。

Content-MD5 ヘッダは、エンドツーエンドで エンティティボディーに含まれるメッセージの完全性チェック (Message Integrity Check - MIC)を提供します。 このヘッダを調べることで、プロキシやクライアントは、 途中経路におけるエンティティボディの予期せぬ変更などを 検出することができます。ヘッダの例:

Content-MD5: AuLb7Dp1rqtRtxz2m9kRpA==

リクエスト毎にメッセージダイジェストを計算する (値はキャッシュされません) ことから、 サーバパフォーマンスが低下することについて注意してください。

Content-MD5は、core 機能により処理された ドキュメントを送るときのみ有効であり、 SSI ドキュメントや CGI スクリプトの出力、バイトレンジを指定した 応答の場合にはこのヘッダは付与されません。

top

DefaultType ディレクティブ

説明:サーバがコンテントタイプを決定できないときに 送られる MIME コンテントタイプ
構文:DefaultType MIME-type|none
デフォルト:DefaultType text/plain
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Core
モジュール:core

サーバは、MIME タイプ のマッピングでは決定できない ドキュメントの送信を要求されることがあります。

サーバは、ドキュメントのコンテントタイプをクライアントに通知するべき(SHOULD)です。 もし通常の方法ではコンテントタイプが分からない場合は、 DefaultType で指定されたタイプを利用します。 例:

DefaultType image/gif

これは .gif という拡張子がファイル名に含まれていない 多くの GIF 画像が含まれているディレクトリに適しているでしょう。

サーバ側でも管理者側(たとえば proxy)でもコンテントタイプが分からない場合で、 MIME タイプの情報が誤ってついているかもしれないぐらいであればむしろ無いほうがよい、 という場合もあるでしょう。このような場合は、次のようにします。

DefaultType None

DefaultType None は httpd-2.2.7 以降で使えます。

ForceType ディレクティブと 違って、このディレクティブはデフォルトの MIME タイプを提供するだけで あることに注意してください。ファイル名の拡張子を含め、 メディアタイプを決定できる他の MIME タイプの定義があれば このデフォルトは上書きされます。

top

<Directory> ディレクティブ

説明:指定のファイルシステムのディレクトリとサブディレクトリとのみに 適用されるディレクティブを囲む
構文:<Directory directory-path> ... </Directory>
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core

指定されたディレクトリとそのサブディレクトリにのみ ディレクティブを適用させるためには、 <Directory></Directory> を対として、ディレクティブ群を囲います。 その中には、ディレクトリコンテキストで許可された全てのディレクティブを 利用できます。 directive-path は、フルパスもしくは Unix のシェル形式の ワイルドカードを指定します。 ? は任意の 1 文字、* は任意の文字列にマッチします。 シェルにおける指定同様、文字の範囲を [] で指定できます。 ワイルドカードは `/' 文字にはマッチしませんので、 /home/user/public_html には <Directory /*/public_html> はマッチしませんが、 <Directory /home/*/public_html> はマッチします。 例:

<Directory /usr/local/httpd/htdocs>
Options Indexes FollowSymLinks
</Directory>

directory-path 引数には注意してください: その引数は Apache がファイルをアクセスするために使うファイルシステムのパスに そのままマッチする必要があります。ある <Directory> に 適用されるディレクティブは、別のシンボリックリンクをたどったりして 同じディレクトリを違うパスでアクセスした場合には適用されません。

~ という文字を 付加することで正規表現を利用することもできます。 例えば:

<Directory ~ "^/www/.*/[0-9]{3}">

といった指定の場合、/www/ 以下にある数字 3 文字のディレクトリにマッチします。

もし複数の (正規表現以外の) <Directory>セクションが ドキュメントを含むディレクトリ (やその上位ディレクトリのどれか) とマッチしたならば、 .htaccess ファイルのディレクティブも読み込みつつ、 短いパスから順に適用されます。 例えば、

<Directory />
AllowOverride None
</Directory>

<Directory /home/>
AllowOverride FileInfo
</Directory>

と設定し、ドキュメント /home/web/dir/doc.html への アクセスがあった場合には以下のように動作します:

  • AllowOverride None が適用される。 (.htaccess ファイルは無効になる)
  • AllowOverride FileInfo が適用される (/home ディレクトリに対して)。
  • /home/.htaccess, /home/web/.htaccess, /home/web/dir/.htaccess の順にそれらのファイル中の FileInfo ディレクティブが適用される。

正規表現は、通常のセクションがすべて適用されるまで 考慮されません。 その後、全ての正規表現が設定ファイルに現れた順で試されます。 例えば、以下のような場合に

<Directory ~ abc$>
# ... directives here ...
</Directory>

正規表現のセクションはすべての通常の <Directory>.htaccess の適用が終わるまで考慮されません。 その後で、正規表現は /home/abc/public_html/abc にマッチし、 対応する <Directory> が適用されます。

Apache のデフォルトでは <Directory /> へのアクセスは Allow from All になっていることに注意してください。 これは、URL からマップされたどのファイルでも Apache は送るということです。 これは以下のようにして変更することが推奨されています。

<Directory />
Order Deny,Allow
Deny from All
</Directory>

そしてアクセスを可能にしたいディレクトリに対して 個別に設定すればよいでしょう。 このあたりについては、セキュリティに関するコツを 参照してください。

ディレクトリセクションは httpd.conf ファイル書きます。 <Directory> ディレクティブは入れ子にすることができず、 <Limit><LimitExcept> セクションの中にも 記述できません。

参照

top

<DirectoryMatch> ディレクティブ

説明:正規表現にマッチするファイルシステムのディレクトリと サブディレクトリとのみに適用されるディレクティブを囲む
構文:<DirectoryMatch regex> ... </DirectoryMatch>
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core

<Directory> ディレクティブと同様に、<DirectoryMatch></DirectoryMatch> は指定されたディレクトリと そのサブディレクトリにのみ適用されるディレクティブ群を囲います。 しかし、このディレクティブは引数として正規表現をとります。例えば:

<DirectoryMatch "^/www/(.+/)?[0-9]{3}">

/www/ 以下にある数字 3 文字のディレクトリにマッチします。

参照

top

DocumentRoot ディレクティブ

説明:ウェブから見えるメインのドキュメントツリーになる ディレクトリ
構文:DocumentRoot directory-path
デフォルト:DocumentRoot /usr/local/apache/htdocs
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core

このディレクティブは、httpd がファイルを提供するディレクトリを設定します。 Alias のようなディレクティブにマッチしない場合には、 ドキュメントの (訳注:ファイルシステム上の) パスを生成するために、 リクエストされた URL のパス部分をドキュメントルートに付与します。 例:

DocumentRoot /usr/web

この場合、 http://www.my.host.com/index.html へのアクセスがあれば /usr/web/index.html が返されます。 directory-path が絶対パスでない場合は、 ServerRoot からの相対パスとみなされます。

DocumentRoot は最後のスラッシュ無しで 指定する必要があります。

参照

top

EnableMMAP ディレクティブ

説明:配送中にファイルを読み込むためにメモリマッピングを 使うかどうか
構文:EnableMMAP On|Off
デフォルト:EnableMMAP On
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Core
モジュール:core

このディレクティブは配送中にファイルの内容を読み込む必要があるときに httpd がメモリマッピングを使うかどうかを制御します。 デフォルトでは、 例えば、mod_include を使って SSI ファイルを配送 するときのように、ファイルの途中のデータをアクセスする必要があるときには Apache は OS がサポートしていればファイルをメモリにマップします。

このメモリマップは性能の向上を持たらすことがあります。 しかし、環境によっては運用上の問題を防ぐためにメモリマッピングを 使用しないようにした方が良い場合もあります:

  • マルチプロセッサシステムの中にはメモリマッピングをすると httpd の性能が落ちるものがあります。
  • NFS マウントされた DocumentRoot では、httpd がメモリマップしている間にファイルが削除されたり 短くなったりしたときに起こるセグメンテーションフォールトのために httpd がクラッシュする可能性があります。

これらの問題に当てはまるサーバの設定の場合は、以下のようにして ファイルの配送時のメモリマッピングを使用不可にしてください:

EnableMMAP Off

NFS マウントされたファイルには、問題のあるファイルにのみ明示的に この機能を使用不可にします:

<Directory "/path-to-nfs-files"> EnableMMAP Off </Directory>

top

EnableSendfile ディレクティブ

説明:ファイルのクライアントへの配送時にカーネルの sendfile サポートを 使うかどうか
構文:EnableSendfile On|Off
デフォルト:EnableSendfile On
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Core
モジュール:core
互換性:バージョン 2.0.44 以降で使用可能

このディレクティブはクライアントにファイルの内容を送るときに httpd がカーネルの sendfile サポートを使うかどうかを制御します。デフォルトでは、 例えば静的なファイルの配送のように、リクエストの処理にファイルの 途中のデータのアクセスを必要としないときには、Apache は OS が サポートしていればファイルを読み込むことなく sendfile を使って ファイルの内容を送ります。

sendfile は read と send を別々に行なうことと、バッファの割り当てを 回避します。しかし、プラットフォームやファイルシステムの中には 運用上の問題を避けるためにこの機能を使用不可にした方が良い場合があります:

  • プラットフォームの中にはビルドシステムが検知できなかった、壊れた sendfile のサポートが存在するものがあります。これは特に バイナリが別のマシンでビルドされ、壊れた sendfile のあるマシンに 移動したときに起こります。
  • Linux では、sendfile を用いると、 IPv6 使用時に存在する特定ネットワークカードの TCP-checksum オフロードのバグを踏んでしまいます。
  • Itanium で動いている Linux で、sendfile は 2GB 以上の ファイルを扱うことができないでしょう。
  • ネットワークマウントされた DocumentRoot (例えば NFS や SMB) では、カーネルは自身のキャッシュを使ってネットワークからのファイルを 送ることができないことがあります。

これらの問題に当てはまるサーバの設定の場合は、以下のようにして この機能を使用不可にしてください:

EnableSendfile Off

NFS や SMB マウントされたファイルには、問題のあるファイルにのみ明示的に この機能を使用不可にします:

<Directory "/path-to-nfs-files"> EnableSendfile Off </Directory>

top

ErrorDocument ディレクティブ

説明:エラーが発生したときにサーバがクライアントに送るもの
構文:ErrorDocument error-code document
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Core
モジュール:core
互換性:Apache 2.0 ではテキストをクウォートする構文が以前のバージョンから 変わっています。

問題やエラーが発生したときの動作として、 Apache には以下の四つのうち一つの動作を設定することができます。

  1. Apache 標準の簡単なエラーメッセージを表示
  2. 自分で指定したメッセージを表示
  3. 問題やエラーの処理をする為に、自サーバ内の URL-path へリダイレクト
  4. 問題やエラーの処理をする為に、外部の URL へリダイレクト

最初のものがデフォルトの動作で、2 番目から 4 番目は、 ErrorDocumentディレクティブにより、 HTTP のレスポンスコードと、メッセージか URL を指定することで設定します。 Apache が問題もしくはエラーに関する追加情報を提供することがあります。

URL の場合は、スラッシュで始まる (/) ローカルの web-path ( DocumentRoot からの相対パス ) か、クライアントが解決できる完全な URL を指定します。 もしくは、ブラウザに表示されるメッセージを指定できます。 例:

ErrorDocument 500 http://foo.example.com/cgi-bin/tester
ErrorDocument 404 /cgi-bin/bad_urls.pl
ErrorDocument 401 /subscription_info.html
ErrorDocument 403 "Sorry can't allow you access today"

加えて、特別な値 default を使って Apache に ハードコードされている簡単なメッセージを指定することができます。 通常は必要ではありませんが、default を使うと 既存の ErrorDocument ディレクティブの設定を 継承するところで、Apache のハードコードされた簡単なメッセージに 戻すことができます。

ErrorDocument 404 /cgi-bin/bad_urls.pl

<Directory /web/docs>
ErrorDocument 404 default
</Directory>

リモート URL (例えば、頭に http と付与した方法) を ErrorDocument に指定するとき、 たとえ文書が同じサーバにあろうとも、ドキュメントがどこにあるかを通知するために、 Apache はリダイレクトをクライアントに送出するということに、注意してください。 これにはいろいろと関連して起こる問題があります。 中でも最も重要なのは、クライアントは元々のエラーステータスコードを受け取らず、 代わりにリダイレクトのステータスコードを受け取るということです。 これにより、ステータスコードを使って URL が有効であるかどうかを決定しようとする ウェブロボットやその他クライアントを、混乱させるかもしれません。 さらに、ErrorDocument 401 にリモートの URL を指定すると、 クライアントは 401 というステータスコードを受け取らないため、 パスワードをユーザーに入力要求しなければならないことがわかりません。 従って、ErrorDocument 401 というディレクティブを使う場合は、 必ずローカルな文書を参照しなければなりません。

Microsoft Internet Explorer (MSIE) はデフォルトではサーバが生成したエラーメッセージが 「小さすぎる」ときには無視をして自分自身の「やさしい」エラーメッセージで 置換します。サイズのしきい値はエラーの種類によって異なりますが、 一般的にはエラーの文書を 512 バイトよりも大きくすると、MSIE は サーバが生成したエラーを隠さずに表示します。詳しい情報は Microsoft Knowledge Base の記事 Q294807 にあります。

ほとんどのエラーメッセージを上書きすることができますが、特定の状況下では ErrorDocument の設定にかかわらず 内蔵のメッセージが使われます。 特に、不正な形式のリクエストが検出された場合、通常のリクエスト処理は 即座に中止され、内蔵のエラーメッセージが返されます。 この処置は不正なリクエストによって引き起こされる、セキュリティ問題から 守るために必要な措置です。

2.0 より前のバージョンでは、対になっていない二重引用符を 先頭に付けることによりメッセージであることを指定していました。

参照

top

ErrorLog ディレクティブ

説明:サーバがエラーをログ収集する場所
構文: ErrorLog file-path|syslog[:facility]
デフォルト:ErrorLog logs/error_log (Unix) ErrorLog logs/error.log (Windows and OS/2)
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core

ErrorLog ディレクティブは、 サーバに生じたさまざまなエラーを 記録する為のファイルの名前を設定します。 file-path が絶対パスでないときは、ServerRoot からの相対パスとみなされます。

ErrorLog /var/log/httpd/error_log

file-path がパイプ (|) から始まる場合は、 エラーログを処理するために実行されるコマンドが 指定されていると解釈されます。

ErrorLog "|/usr/local/bin/httpd_errors"

ファイル名の変わりに syslog と指定することによって、 システムがサポートしていれば syslogd(8) を利用したロギングが有効になります。 デフォルトでは、local7 ファシリティとなりますが、 syslog:facility といった形で記述することにより、 通常 syslog(1) のドキュメントで説明されているファシリティの一つを使うように することができます。

ErrorLog syslog:user

セキュリティ: ログファイルを格納するディレクトリが、サーバを起動したユーザ以外の ユーザによって書き込める場合にセキュリティが破られる可能性があることに 関する詳細は セキュリティに関するコツ を 参照してください。

Unix 以外のプラットフォームでファイルのパスを入力するときは、 プラットフォームがバックスラッシュの使用を許していたとしても、 確実にスラッシュのみが使用されるように注意してください。一般的には、 設定ファイル全般でスラッシュのみを使う方が良いでしょう。

参照

top

FileETag ディレクティブ

説明:ETag HTTP 応答ヘッダを作成するために使用される ファイルの属性
構文:FileETag component ...
デフォルト:FileETag INode MTime Size
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Core
モジュール:core

FileETag ディレクティブは ドキュメントがファイルに基づいたものであるときに、 ETag (エンティティタグ) 応答ヘッダフィールドを作成するときに使用する ファイルの属性を設定します。 (ETag の値はネットワークの帯域を節約するための キャッシュの管理で使われます。) Apache 1.3.22 以前では、ETag の値は 常にファイルの inode, サイズ、最終修正時刻 (mtime) から作成 されていました。FileETag ディレクティブにより、これらのどれを使うかを 選ぶことができます。認識されるキーワードは:

INode
ファイルの inode 番号を計算に使います
MTime
ファイルの最終修正時刻を使います
Size
ファイルの中身のバイト数を使います
All
使用可能なすべてのフィールドを使います。 これは

FileETag INode MTime Size

と等価です。
None
ドキュメントがファイルに基づいたものでも、ETag フィールドを 応答に付加しません

INode, MTime, Size キーワードには +- を前に付けて 指定することもできます。この場合は、より広い範囲から継承された デフォルトの設定に変更を加えるようになります。そのような接頭辞の 無いキーワードを指定すると、即座に継承した設定を無効にします。

あるディレクトリの設定に FileETag INode MTime Size があり、 サブディレクトリの設定に FileETag -INode があるときは、 そのサブディレクトリの設定は (設定が上書きされなければサブディレクトリの サブディレクトリにも継承されます) FileETag MTime Size と同じになります。

警告

WebDAV を使っていて、mod_dav_fs をストレージプロバイダとして 使っているような Directory や Location では、デフォルト値を変更しないでください。 条件つきリクエスト中で、mod_dav_fs では INode MTime Size という形式の固定フォーマットであることを前提として ETag の比較を行っています。もし ETag フォーマットを FileETag で変えてしまうと、条件つきリクエストが うまく動作しなくなるでしょう。
top

<Files> ディレクティブ

説明:マッチするファイル名に適用されるディレクティブを囲む
構文:<Files filename> ... </Files>
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Core
モジュール:core

<Files> ディレクティブは、 その中にあるディレクティブの適用範囲をファイル名で制限します。 <Directory> ディレクティブや <Location> ディレクティブと 同じような機能を持ちます。 これは、</Files> ディレクティブと対に なっていなければなりません。 このセクション中のディレクティブは、ベース名 (ファイル名の最後の部分) が指定されたファイル名にマッチするすべてのオブジェクトに適用されます。 <Files> セクションは <Directory> セクションと .htaccess が読み込まれた後、 <Location> セクションよりは先に 設定ファイルに現れた順に適用されます。 <Files> は、 <Directory> セクション内に ネストさせることができ、 ファイルシステムの一部にのみ限定して適用させることができます。

filename 引数は、ファイル名かワイルドカード文字列 で、ワイルドカードでは ? は一つの文字、* は任意の文字列にマッチします。 ~ という文字を付加することで正規表現を使うこともできます。 例えば、

<Files ~ "\.(gif|jpe?g|png)$">

とすることにより、一般的なインターネットの画像フォーマットにマッチします。 ただし、 <FilesMatch> を使う方が 推奨されています。

ちなみに、<Directory><Location> セクションとは異なり、 <Files>.htaccess ファイル内で利用することができます。 これにより、ユーザがファイル毎にアクセスの制御を行なうことができるように なっています。

参照

top

<FilesMatch> ディレクティブ

説明:正規表現にマッチするファイル名に適用される ディレクティブを囲む
構文:<FilesMatch regex> ... </FilesMatch>
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Core
モジュール:core

<FilesMatch> ディレクティブは、 <Files> ディレクティブ同様にその中にあるディレクティブの適用範囲をファイル名で制限します。ただし、 このディレクティブには正規表現を指定します。 例えば:

<FilesMatch "\.(gif|jpe?g|png)$">

は一般的なインターネットの画像形式にマッチします。

参照

top

ForceType ディレクティブ

説明:すべてのマッチするファイルが指定の MIME コンテントタイプで 送られるようにする
構文:ForceType MIME-type|None
コンテキスト:ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Core
モジュール:core
互換性:Apache 2.0 で core に移動

.htaccess<Directory> セクション、 <Location> セクション、 <Files> セクションに 書かれた場合、このディレクティブはそこにあるすべてのファイルが MIME-type で指定されたコンテントタイプとして扱われるようにします。たとえば、 GIF ファイルばかりのディレクトリがあって、すべてのファイルを .gif で終わらせたくはないときに、以下のものを使用します:

ForceType image/gif

DefaultType と違って このディレクティブはメディアタイプを決めることができるかもしれない ファイルの拡張子も含め、すべての MIME タイプの関連付けを 上書きすることに注意してください。

None という値を使うことで ForceType の 設定を無効にできます:

# force all files to be image/gif:
<Location /images>
ForceType image/gif
</Location>

# but normal mime-type associations here:
<Location /images/mixed>
ForceType None
</Location>

top

HostnameLookups ディレクティブ

説明:クライアントの IP アドレスの DNS ルックアップを 有効にする
構文:HostnameLookups On|Off|Double
デフォルト:HostnameLookups Off
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ
ステータス:Core
モジュール:core

このディレクティブは、ホスト名をログ収集できるように DNS ルックアップを有効にします (さらに、CGI/SSI に REMOTE_HOST 変数として渡します)。 Doubleを指定した場合、2 重の逆引きを行ないます。 つまり、逆引きの後に、その結果に対して正引きを行ないます。正引きの 結果の IP アドレスの中にオリジナルのアドレスと一致するものがなければ なりません。("tcpwrappers" の用語では PARANOID と呼ばれています。)

mod_authz_host でホスト名によるアクセス 制御を行なう場合には、 設定の如何によらず 2 重の逆引きが実行されます。 これは、セキュリティを保つために必要です。 HostnameLookups Double を設定しない限り、 他の部分はこの 2 重逆引きの結果を使うことはできません。 例えば、HostnameLookups On と設定してある状態で、 ホスト名によるアクセス制限を行なったオブジェクトへの リクエストを受けたとすると、2 重の逆引きが成功するか否かによらず、 REMOTE_HOST には通常の逆引き結果が渡されます。

ディレクティブのデフォルトは 本当に逆引きを必要としているわけではないサイトの ネットワークトラフィックを低減させるために、Off になっています。 ルックアップによる余計な遅延がなくなるため、 エンドユーザにとっても良いでしょう。 DNS のルックアップには、かなりの時間が必要となる場合が多く、 負荷の高いサイトではこのディレクティブは Off にすべきです。 なお、/support ディレクトリに含まれ、デフォルトでは インストールディレクトリの bin サブディレクトリに インストールされる logresolve ユーティリティにより、 Apache の動作とは別に、ログに残されている IP アドレスからホスト名を ルックアップすることが可能です。

top

<IfDefine> ディレクティブ

説明:起動時にテストが真であるときのみに処理されるディレクティブを 囲む
構文:<IfDefine [!]parameter-name> ... </IfDefine>
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Core
モジュール:core

<IfDefine test>...</IfDefine> セクションは、 ディレクティブを条件付きで指定するために利用します。 <IfDefine> セクションに 含まれるディレクティブは、testが 定義されているときのみ処理されます。 もし test が定義されていなければ、 開始と終了の指定の間のディレクティブは無視されます。

<IfDefine> セクションディレクティブに 指定する test は、 次の二つの形式のうちの一つをとります:

  • parameter-name
  • !parameter-name

前者の場合には、parameter-name と名付けられたパラメータが 定義されていれば開始と終了の間のディレクティブが処理されます。 後者の場合は逆で、parameter-name が指定されていない 場合に処理されます。

parameter-name 引数は、サーバを起動する際に httpd のコマンドラインに -Dparameter- という形で指定すると定義されます。

<IfDefine> セクションは 入れ子にすることができ、複数のパラメータによるテストをするために使用できます。 例:

httpd -DReverseProxy ...

# httpd.conf
<IfDefine ReverseProxy>
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/libproxy.so
</IfDefine>

top

<IfModule> ディレクティブ

説明:モジュールの存在するかしないかに応じて処理される ディレクティブを囲む
構文:<IfModule [!]module-file|module-identifier> ... </IfModule>
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Core
モジュール:core
互換性:モジュール識別子はバージョン 2.1 以降で使用可能。

<IfModule test>...</IfModule> セクションは、モジュールが存在するときに処理されるディレクティブを 指定するために利用します。 <IfModule> セクションに 含まれるディレクティブは、test で指定するモジュールが組み込まれているときのみ処理されます。 もし test が組み込まれていなければ、開始と終了の間のディレクティブ は無視されます。

<IfModule> セクションディレクティブに 指定する test は、 次の二つの形式のうちの一つをとります。

  • module
  • !module

前者の場合は、module と名付けられたモジュールが Apache に組み込まれていれば (コンパイル済みのものと、LoadModule を利用して 動的に読み込んだものの両方)、 開始と終了の間のディレクティブが処理されます。 後者の場合は逆で、module が組み込まれていない 場合に処理されます。

module 引数は、モジュール識別子か コンパイルをした時のモジュールのファイル名です。 例えば、rewrite_module は識別子で mod_rewrite.c はファイル名です。 モジュールが複数のソースファイルから構成されている場合は、文字列 STANDARD20_MODULE_STUFF があるファイルの名前を 使ってください。

<IfModule> セクションは 入れ子にすることが可能であり、 複数のモジュールのテストを行なうために使用できます。

特定のモジュールの存在に関わらず動作する 設定ファイルの原本が必要なときにのみこのセクションを使用してください。 通常の動作では、ディレクティブを <IfModule> セクションの中に 入れる必要はありません。
top

Include ディレクティブ

説明:サーバ設定ファイル中から他の設定ファイルを取り込む
構文:Include file-path|directory-path
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ
ステータス:Core
モジュール:core
互換性:ワイルドカードによるマッチは 2.0.41 以降で使用可能

このディレクティブにより、サーバの設定ファイルから 他の設定ファイルをインクルードすることができます。

複数のファイルをアルファベット順に一度に読み込むために、 シェル形式 (fnmatch) のワイルドカード文字を使うことができます。 さらに、Include にディレクトリを指定した場合は、 ディレクトリとそのサブディレクトリ内の全てのファイルを アルファベット順に読み込んで、設定ファイルとして処理します。 しかし、ディレクトリ全体を読み込むのはお勧めできません。 ふとしたことから httpd が読み込みに失敗するような 一時ファイルをディレクトリに残してしまうようなことがよくあるからです。

指定するファイルパスは絶対パスか、 ServerRoot ディレクトリからの 相対パスか、のどちらかです。

例:

Include /usr/local/apache2/conf/ssl.conf
Include /usr/local/apache2/conf/vhosts/*.conf

ServerRoot からの相対パスの場合は:

Include conf/ssl.conf
Include conf/vhosts/*.conf

apachectl configtest を実行すると、設定をチェックしている時に 読み込まれたファイルのリストが表示されます:

root@host# apachectl configtest
Processing config file: /usr/local/apache2/conf/ssl.conf
Processing config file: /usr/local/apache2/conf/vhosts/vhost1.conf
Processing config file: /usr/local/apache2/conf/vhosts/vhost2.conf
Syntax OK

参照

top

KeepAlive ディレクティブ

説明:HTTP の持続的な接続を有効にする
構文:KeepAlive On|Off
デフォルト:KeepAlive On
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core

HTTP/1.0 の Keep-Alive 拡張と HTTP/1.1 の持続的接続の機能は、 複数のリクエストが同じ TCP の接続で送られる、長時間持続する HTTP セッションを提供します。たくさんの画像が 含まれる HTML ドキュメントでは場合によっては遅延時間が 50% 短縮される結果も でています。Keep-Alive 接続を有効にするには KeepAlive On と設定します。

HTTP/1.0 に対応したクライアントの際には、 クライアントより特に要求があった場合のみ Keep-Alive 接続となります。 さらに、HTTP/1.0 クライアントでは、コンテンツの容量が先に (訳注: 要求に対して応答を返す前に) わかる場合のみ Keep-Alive 接続を利用できます。 これは、CGI の出力や SSI のページ、 サーバが生成したディレクトリのリストのような動的コンテンツを HTTP/1.0 クライアントに送る場合には Keep-Alive 接続を使えないことを意味します。 HTTP/1.1 に対応したクライアントの際には、 特に指定されない限りはデフォルトとして持続的な接続が行なわれます。 クライアントが要求すれば、コンテンツの容量を判別できないものを 持続的な接続を通して送るために、チャンクエンコーディングが用いられます。

参照

top

KeepAliveTimeout ディレクティブ

説明:持続的な接続で次のリクエストが来るまでサーバが待つ時間
構文:KeepAliveTimeout seconds
デフォルト:KeepAliveTimeout 5
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core

接続を閉じる前に、Apache が次のリクエストを何秒待つかを指定します。 リクエストを受け付けた後は、Timeout ディレクティブによって 指定されたタイムアウト値が使われます。

KeepAliveTimeout を大きな値に設定すると、 負荷の高いサーバにおいてはパフォーマンスの問題を引き起こす場合があります。 タイムアウトが長ければ長いほど、より多くのサーバプロセスが 活発でないクライアントからの接続の終了を待ち続けることになります。

top

<Limit> ディレクティブ

説明:囲いの中にあるアクセス制御の適用を特定の HTTP メソッドのみに 制限する
構文:<Limit method [method] ... > ... </Limit>
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Core
モジュール:core

アクセス制御は、通常全てのアクセスメソッドに対して 影響し、普通はこれが望ましい挙動です。 そうしたことから、大部分の場合にはアクセス制御に関わるディレクティブを <Limit> セクション内に 書くべきではありません。

<Limit> ディレクティブの 目的は、アクセス制御の範囲を 指定された HTTP メソッドに限定するためです。 それ以外のメソッドは、<Limit> で囲われたアクセス制御の 影響を受けません。 以下の例は、POST, PUT, DELETE のメソッドに対してのみアクセスの制御を行ない、 それ以外のメソッドについては制限しません:

<Limit POST PUT DELETE>
Require valid-user
</Limit>

メソッド名には以下の中から一つ以上を列挙することができます: GET, POST, PUT, DELETE, CONNECT, OPTIONS, PATCH, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK. メソッド名は 大文字小文字を区別します。 GET を指定した場合には HEAD リクエストにも制限がかかります。TRACE メソッドに制限をかけることはできません。

アクセス制御が目的の場合は <Limit> セクションの代わりに <LimitExcept> セクションを使用した方が良いでしょう。 <LimitExcept> セクションでは不特定のメソッドに対しても防御できるからです。
top

<LimitExcept> ディレクティブ

説明:指定されたもの以外の HTTP メソッドにアクセス制御を 制限する
構文:<LimitExcept method [method] ... > ... </LimitExcept>
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Core
モジュール:core

<LimitExcept></LimitExcept> は、引数に 含まれていない HTTP のアクセスメソッドに適用するためのアクセス制御 ディレクティブを括るために利用します。 つまり、<Limit> セクションの反対の動作をし、 標準のメソッドと標準外や未認識のメソッドの場合の両方を設定できます。 <Limit> のドキュメントも 併せて参照してください。

例:

<LimitExcept POST GET>
Require valid-user
</LimitExcept>

top

LimitInternalRecursion ディレクティブ

説明:内部リダイレクトと入れ子になったサブリクエストの最大数を決定する
構文:LimitInternalRecursion number [number]
デフォルト:LimitInternalRecursion 10
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core
互換性:Apache 2.0.47 以降で使用可能

内部リダイレクトは例えば Action ディレクティブを 使っているときに起こります。Action ディレクティブは 元々のリクエストを CGI スクリプトに内部リダイレクトを行ないます。 サブリクエストはいくつかの URI に対して、リクエストされたときに 何が起こるかを調べるための Apache の機構です。例えば、mod_dirDirectoryIndex ディレクティブ がリストするファイルを調べるためにサブリクエストを使います。

LimitInternalRecursion は内部リダイレクトや サブリクエストが無限ループに陥ったときのサーバクラッシュを防ぎます。 普通、そのようなループは設定に失敗したときに発生します。

このディレクティブは、リクエスト毎に評価される、二つの違う限界値を 設定します。最初の number は、起こり得る 内部リクエストの最大値を設定します。二つめの number は サブリクエストが入れ子にできる深さを設定します。number を 一つだけ指定したときは、両方の限界値にその値が設定されます。

LimitInternalRecursion 5

top

LimitRequestBody ディレクティブ

説明:クライアントから送られる HTTP リクエストのボディの 総量を制限する
構文:LimitRequestBody bytes
デフォルト:LimitRequestBody 0
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Core
モジュール:core

このディレクティブは、リクエストボディに許されるバイト数、bytes を 0 (無制限を意味します) から 2147483647 (2GB) までの数値で指定します。

LimitRequestBody ディレクティブは、 ディレクティブが書かれたコンテキスト (サーバ全体、ディレクトリ、ファイル、ロケーション) 内で 許容する HTTP リクエストメッセージボディのサイズに制限をかけることができます。 クライアントのリクエストがその制限値を越えていれば、 サーバはリクエストを処理せずにエラーを返します。 普通のリクエストメッセージボディのサイズは、リソースの種類や 許可されているメソッドによって大きく変わります。 CGI スクリプトは、よく情報を受信するために メッセージボディを使います。 PUT メソッドの実装は、このディレクティブの値として 少なくともあるリソースに対してサーバが受け付けようとする 表現の大きさほどの値を必要とします。

このディレクティブは、 管理者にクライアントからの異常なリクエストを制御できるようにし、 何らかの形のサービス拒否攻撃 (訳注:DoS) を避けるのに有効です。

ある場所へのファイルアップロードを許可する場合に、 アップロードできるファイルのサイズを 100K に制限したければ、 以下のように指定します:

LimitRequestBody 102400

top

LimitRequestFields ディレクティブ

説明:クライアントからの HTTP リクエストのヘッダフィールドの数を 制限する
構文:LimitRequestFields number
デフォルト:LimitRequestFields 100
コンテキスト:サーバ設定ファイル
ステータス:Core
モジュール:core

number には、0 (無制限を意味します) から 32767 までの整数を指定します。 デフォルト値は、定数 DEFAULT_LIMIT_REQUEST_FIELDS によりコンパイル時に定義されます (配布時には 100 と指定されています)。

LimitRequestBody ディレクティブは、 サーバ管理者が HTTP リクエスト中において許可するリクエストヘッダフィールド数を 指定します。 サーバはこの値には通常のクライアントからのリクエストに含まれるであろう フィールドの数より大きな値が必要とします。 クライアントにより使われた要求ヘッダーフィールドの数が 20 を超えることはほとんどありませんが、 これは種々のクライアントの実装によって変わり、 詳細なコンテントネゴシエーションをするためのブラウザの設定までにも 影響されることがあります。 オプションの HTTP 拡張はリクエストヘッダフィールドを使って表される場合が 多くあります。

このディレクティブは、 管理者にクライアントからの異常なリクエストを制御できるようにし、 何らかの形のサービス拒否攻撃 (訳注:DoS) を避けるのに有効です。 リクエストのフィールドが多過ぎることを意味するエラー応答が 普通のクライアントに返されるような時はこの値を増やしてください。

例:

LimitRequestFields 50

top

LimitRequestFieldSize ディレクティブ

説明:クライアントからの HTTP リクエストのヘッダの サイズを制限する
構文:LimitRequestFieldSize bytes
デフォルト:LimitRequestFieldSize 8190
コンテキスト:サーバ設定ファイル
ステータス:Core
モジュール:core

このディレクティブは、HTTP リクエストヘッダ一つで受付ける バイト数 bytes を指定します。

LimitRequestFieldSize ディレクティブは、 HTTP リクエストヘッダで許容されるサイズを増減させることができます。 サーバは、このディレクティブの値として、 一般的なクライアントからリクエストが送られた際に、そのリクエストに 付属しているどのヘッダフィールドについても、 十分足りる大きさになっていなければなりません。 一般的なリクエストヘッダのサイズといっても、その大きさは個々の クライアントの実装によって大きく異なり、 詳細なコンテントネゴシエーションをサポートするかどうかの、 ブラウザの設定にも影響されたりします。 SPNEGO 認証ヘッダでは 12392 バイトにまで及ぶことすらあります。

このディレクティブは、 管理者にクライアントからの異常なリクエストを制御できるようにし、 何らかの形のサービス拒否攻撃 (訳注:DoS) を避けるのに有効です。

例:

LimitRequestFieldSize 4094

通常はデフォルトから変更する必要はありません。
top

LimitRequestLine ディレクティブ

説明:クライアントからの HTTP リクエスト行のサイズを制限する
構文:LimitRequestLine bytes
デフォルト:LimitRequestLine 8190
コンテキスト:サーバ設定ファイル
ステータス:Core
モジュール:core

このディレクティブは、HTTP リクエスト行内で許容されるバイト数 bytes を指定します。

LimitRequestLine ディレクティブにより、 クライアントからの HTTP リクエスト行の許容サイズを増減できます。 リクエスト行は、HTTPメソッド、URI、プロトコルバージョンから成っており、 LimitRequestLine はサーバへのリクエストに対して 許容するリクエスト URI の長さを制限することになります。 サーバは、GET リクエストのクエリ部分も含めて、リソースの名前が入るに足る 大きさを必要とします。

このディレクティブは、 管理者にクライアントからの異常なリクエストを制御できるようにし、 何らかの形のサービス拒否攻撃 (訳注:DoS) を避けるのに有効です。

例:

LimitRequestLine 4094

通常はデフォルトから変更する必要はありません。
top

LimitXMLRequestBody ディレクティブ

説明:XML 形式のリクエストのボディのサイズを制限する
構文:LimitXMLRequestBody bytes
デフォルト:LimitXMLRequestBody 1000000
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Core
モジュール:core

XML 形式のリクエストのボディの最大値を (バイト単位で) 制限します。 値に 0 を指定するとチェックを無効にします。

例:

LimitXMLRequestBody 0

top

<Location> ディレクティブ

説明:囲んだディレクティブをマッチする URL のみに適用
構文:<Location URL-path|URL> ... </Location>
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core

<Location> ディレクティブは、 URL により中に書かれたディレクティブの適用範囲を制限します。 <Directory> ディレクティブと似ていて、 </Location> ディレクティブで終了する サブセクションを開始します。 <Location> セクションは、 <Directory> セクションと .htaccess の読み込みの後、 <Files> セクションを 適用した後に、設定ファイルに現れた順に処理されます。

<Location> セクションは 完全にファイルシステムと関連せずに動作します。このことから導かれる 結果にはいつくか注意する点があります。最も重要なものは、 ファイルシステムの位置へのアクセス制御に <Location> ディレクティブを使うべきではない ということです。複数の URL がファイルシステムの同じ位置にマップされる 可能がありますので、そのようなアクセス制御は回避されてしまう可能性が あります。

いつ <Location> を使うか

<Location> ディレクティブは ファイルシステム外のコンテンツにディレクティブを適用するときに 使用してください。ファイルシステムに存在するコンテンツに対しては、 <Directory><Files> を使ってください。 例外は、<Location /> で、これはサーバ全体に対して 設定を適用する簡単な方法です。

全ての (プロキシ以外の) リクエストに対し、 URL は /path/ という、 接頭辞 http://servername を含まない形でマッチします。 プロキシリクエストの場合には、scheme://servername/path という接頭辞を含む形でマッチし、接頭辞を含めて指定する必要があります。

URL にはワイルドカードを利用することができます。 ? は任意の一文字、* は任意の文字列にマッチします。 どちらのワイルドカード文字も URL-path の / にはマッチしません。

~ という文字を追加することで、正規表現を 利用することもできます。 例えば:

<Location ~ "/(extra|special)/data">

は URL に /extra/data/special/data という文字列が 含まれている場合にマッチします。 <LocationMatch> ディレクティブは <Location> の正規表現 版とまったく同じ動作をします。

<Location> 機能は、SetHandler ディレクティブと 組合わせて利用すると特に便利です。 例えば、foo.com のブラウザからのみステータスの参照を有効にしたければ、 次のようにすれば良いでしょう。

<Location /status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from .foo.com
</Location>

/ (スラッシュ) に関する注

スラッシュ文字は、URL 内に現れる場所に応じて変化する 特別な意味を持っています。 ファイルシステムにおいて利用する場合には複数のスラッシュでも一つの スラッシュとして扱われることが多いですが、 (すなわち/home///foo/home/foo と同じいったように) URL においては必ずしもそうなるわけではありません。 <LocationMatch> ディレクティブや正規表現を利用した <Location> ディレクティブで、 複数のスラッシュにマッチさせたいときには、、明示的に記述する 必要があります。

例えば、<LocationMatch ^/abc> は、 /abc というリクエスト URL にマッチしますが、 //abc というリクエスト URL にはマッチしません。 (正規表現でない) <Location> ディレクティブは、 proxy リクエストに対して利用する際には同様の振る舞いをしますが、 (正規表現でない) <Location> を proxy でないリクエストに対して利用する際には、 一つのスラッシュで複数のスラッシュにマッチします。 例えば、<Location /abc/def> と指定し、 /abc//def というリクエストがあれば、 マッチすることになります。

参照

top

<LocationMatch> ディレクティブ

説明:囲んだディレクティブを正規表現にマッチする URL のみに 適用
構文:<LocationMatch regex> ... </LocationMatch>
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core

<LocationMatch> ディレクティブは、 <Location> と同じ様に URL により中に書かれたディレクティブの適用範囲を制限します。 但し、引数は普通の文字列ではなく、正規表現となります。 例えば、

<LocationMatch "/(extra|special)/data">

は URL に /extra/data/special/data という文字列が含まれている場合にマッチします。

参照

top

LogLevel ディレクティブ

説明:ErrorLog の冗長性を制御する
構文:LogLevel level
デフォルト:LogLevel warn
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core

LogLevel は、エラーログ (ErrorLog ディレクティブを 見てください) へ記録するメッセージの冗長性を調整します。 以下の level を指定でき、順に重要度が下がっていきます。

レベル 説明
emerg 緊急 - システムが利用できない Child cannot open lock file. Exiting (子プロセスがロックファイルを開けないため終了した)
alert 直ちに対処が必要 getpwuid: couldn't determine user name from uid (getpwuid: UID からユーザ名を特定できなかった)
crit 致命的な状態 socket: Failed to get a socket, exiting child (socket: ソケットが得られないため、子プロセスを終了させた)
error エラー Premature end of script headers (スクリプトのヘッダが足りないままで終わった)
warn 警告 child process 1234 did not exit, sending another SIGHUP (子プロセス 1234 が終了しなかった。もう一度 SIGHUP を送る)
notice 普通だが、重要な情報 httpd: caught SIGBUS, attempting to dump core in ... (httpd: SIGBUS シグナルを受け、... へコアダンプをした)
info 追加情報 "Server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers)..." (「サーバは負荷が高い、 (StartServers や Min/MaxSpareServers の値を増やす必要があるかも)」)
debug デバッグメッセージ "Opening config file ..." (設定ファイルを開いている...)

特定のレベルが指定された場合、それより高いレベルの全てのメッセージが 報告されます。 例えばLogLevel info に指定すると、 noticewarn も報告されます。

なお crit 以上のレベルを指定することが推奨されます。

例:

LogLevel notice

ファイルにログを出力する場合、notice レベルのメッセージは抑制されず、すべてログに出力されます。 しかし syslog を使用している場合は、 これは当てはまりません。

top

MaxKeepAliveRequests ディレクティブ

説明:持続的な接続上で許可されるリクエストの数
構文:MaxKeepAliveRequests number
デフォルト:MaxKeepAliveRequests 100
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core

MaxKeepAliveRequests ディレクティブは、 KeepAlive が有効な場合に、 一回の接続で受け付け可能なリクエストの数を制限します。 0 に設定していれば、受け付けるリクエストは無制限になります。 この設定は、サーバ性能を向上させるために、大きな数値を指定すること勧めます。

例:

MaxKeepAliveRequests 500

top

NameVirtualHost ディレクティブ

説明:名前ベースのバーチャルホストのための IP アドレスを指定
構文:NameVirtualHost addr[:port]
コンテキスト:サーバ設定ファイル
ステータス:Core
モジュール:core

NameVirtualHost ディレクティブは、 名前ベースのバーチャルホストの設定を行ないたい場合に 必要となるものです。

addr にはホスト名を指定できますが、 常に IP アドレスを指定するのが推奨されます。 例えば、

NameVirtualHost 111.22.33.44

NameVirtualHost ディレクティブは、 名前ベースのバーチャルホストを 利用してリクエストを受け付ける IP アドレスを指定します。 これは、普通は名前ベースのバーチャルホストアドレスです。 ただし、ファイアーウォールや他のプロキシがリクエストを受け付け、 違う IP アドレスのサーバにフォワードするという場合は、 リクエストを提供したいマシン上の物理インターフェースの IP アドレスを指定する必要があります。 複数のアドレスで複数の名前ベースのバーチャルホストを指定する場合は 各アドレスに対してディレクティブを書いてください。

「主サーバ」や、どの _default_ サーバも、 NameVirtualHost で指定した IP アドレスへのリクエスト を処理することはありません (なぜか NameVirtualHost を 指定したけどそのアドレスに VirtualHost を定義しなかった場合を除く)。

名前ベースのバーチャルホストにポート番号を指定することも可能です。 例えば

NameVirtualHost 111.22.33.44:8080

IPV6 のアドレスは次の例のように角括弧で囲む必要があります:

NameVirtualHost [2001:db8::a00:20ff:fea7:ccea]:8080

すべてのインタフェースへのリクエストを受け取るようにするためには、 引数として * を使います。

NameVirtualHost *

<VirtualHost> ディレクティブの引数

<VirtualHost> ディレクティブの引数は NameVirtualHost ディレクティブの引数に正確に 合っている必要があることに注意してください。

NameVirtualHost 1.2.3.4
<VirtualHost 1.2.3.4>
# ...
</VirtualHost>

参照

top

Options ディレクティブ

説明:ディレクトリに対して使用可能な機能を設定する
構文:Options [+|-]option [[+|-]option] ...
デフォルト:Options All
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Options
ステータス:Core
モジュール:core

Options ディレクティブは、特定のディレクトリに対して どの機能が使用可能かを制御します。

optionNoneに指定すると、 特別な機能は全て無効になります。 また、以下の示す 1 個以上のものを指定できます。

All
MultiViews を除いた全ての機能が有効となります。 これがデフォルトです。
ExecCGI
mod_cgi による CGI スクリプトの実行を許可します。
FollowSymLinks
サーバが、このディレクトリ内でシンボリックリンクをたどれるようにします。

サーバがシンボリックリンクをたどる場合でも、 <Directory> セクションに マッチさせるための パス名は変更されません

<Location> 内に このオプションを指定しても無視されることに 注意してください。

このオプションを省略したからといってセキュリティの強化にはなりません。 なぜなら symlink の検査はレースコンディションを引き起こす可能性があり、 そのため回避可能になるからです。

Includes
mod_include が提供する SSI を有効にします。
IncludesNOEXEC
SSI は有効になりますが、#exec コマンド と #exec CGI は無効になります。 ただし、#include virtual により、ScriptAlias されたディレクトリで CGI を実行することは可能です。
Indexes
もし、URL がディレクトリにマップするリクエストであって、 且つ DirectoryIndex で指定したファイル (例えば、index.html) が ディレクトリ内に無ければ、mod_autoindex が ディレクトリ内の一覧を整形して返します。
MultiViews
mod_negotiation による コンテントネゴシエーション された "MultiViews" を許可します。
SymLinksIfOwnerMatch
シンボリック先のファイルまたはディレクトリが、 シンボリックリンクの所有ユーザ ID と同じ場合にのみシンボリックリンクを たどれるようにします。

<Location> 内にこのオプションを 指定しても無視されます。

このオプションはセキュリティの強化にはなりません。 なぜなら symlink の検査はレースコンディションを引き起こす可能性があり、 そのため回避可能になるからです。

通常、ディレクトリに対して複数の Options が 適用可能な場合、 最も近いもの一つのみが適用され、他のものは無視されます。 複数の指定がマージされるわけではありません。(セクションのマージ方法を参照してください。) しかし、すべての Options ディレクティブが +- 付きで 指定された場合はオプションの値はマージされます。 + を頭につければ現在の設定に加えられ、 - を付ければ現在の設定から削除されます。

警告

Options で指定する際に、 +- のついたものと、ついていないものを 混ぜて指定する記述は誤った構文で、予期しない結果になるかもしれません。

例えば、+- を利用しない場合は:

<Directory /web/docs>
Options Indexes FollowSymLinks
</Directory>

<Directory /web/docs/spec>
Options Includes
</Directory>

/web/docs/spec というディレクトリには、 Includes だけが適用されます。 しかし、2 番目の Options+- を利用してみると:

<Directory /web/docs>
Options Indexes FollowSymLinks
</Directory>

<Directory /web/docs/spec>
Options +Includes -Indexes
</Directory>

/web/docs/spec というディレクトリには、 FollowSymLinksIncludes が適用されます。

-IncludesNOEXEC もしくは -Includes を指定すると、 前の設定がどのようになっていようとも SSI は無効となります。

どのような設定もされていなければ、デフォルトでは All に なります。

top

Require ディレクティブ

説明:どの認証済みユーザがリソースをアクセスできるかを選択する
構文:Require entity-name [entity-name] ...
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Core
モジュール:core

このディレクティブは、認証されたユーザがリソースに対して アクセスできるかを制御します。 制限条件は承認モジュールで処理されます。 mod_authz_usermod_authz_groupfile で提供されている構文には、次のようなものもあります:

Require user userid [userid] ...
指定されたユーザのみ、ディレクトリへのアクセスを許可します。
Require group group-name [group-name] ...
指定されたグループに属するユーザのみ、ディレクトリへのアクセスを許可します。
Require valid-user
全ての認証されたユーザに、ディレクトリへのアクセスを許可します。

require オプションを実装している他の承認モジュールには、 mod_authnz_ldap, mod_authz_dbm, mod_authz_owner といったものがあります。

Require は、正しく動作するためには AuthName 及び AuthType ディレクティブや、 (ユーザとグループを指定するために) AuthUserFile 及び AuthGroupFile といったディレクティブと共に 指定する必要があります。 例えば:

AuthType Basic
AuthName "Restricted Resource"
AuthUserFile /web/users
AuthGroupFile /web/groups
Require group admin

このようにして適用されたアクセス制御は、全てのメソッドに 対して行なわれます。 通常は、これが望ましい動作です。 もし、特定のメソッドに対してのみアクセスの制御を適用し、 他のメソッドは制限しない場合には、<Limit> セクション内に Require を 指定してください。

RequireAllow ディレクティブや Deny ディレクティブと 組み合わせて使った場合、これらの制約の相互作用は Satisfy ディレクティブで制御されます。

サブディレクトリで制御を解除する方法

Satisfy ディレクティブ で、保護されたディレクトリのサブディレクトリ内でアクセス制御を 無効にする例は、下のようになります。 mod_authz_host によるアクセス制御も無効化されるので、 このテクニックは注意してご活用ください。

<Directory /path/to/protected/>
Require user david
</Directory>
<Directory /path/to/protected/unprotected>
# All access controls and authentication are disabled
# in this directory
Satisfy Any
Allow from all
</Directory>

参照

top

RLimitCPU ディレクティブ

説明:Apache の子プロセスから起動されたプロセスの CPU 消費量を 制限する
構文:RLimitCPU seconds|max [seconds|max]
デフォルト:未設定。オペレーティングシステムのデフォルトを使用
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Core
モジュール:core

一つか二つのパラメータをとります。 最初のパラメータは全プロセスに対するリソースのソフトリミットを設定し、 2 番目のパラメータは最大のリソースリミットを設定します。 パラメータには数字か、オペレーティングシステムの最大となる max のどちらかを指定することができます。 最大のリソースリミットを上げるためには、サーバを root で実行するか起動されなければいけません。

ちなみに、この設定は Apache の子プロセス自体ではなく、 リクエストを受け付けた Apache の子プロセスから fork されたプロセスに 適用されます。 これには CGI や SSI から実行されたコマンドが含まれますが、Apache の 親プロセスから fork されたログのパイププロセスなどには適用されません。

CPU リソースのリミットはプロセスあたりの秒数で表わされます。

参照

top

RLimitMEM ディレクティブ

説明:Apache の子プロセスから起動されたプロセスのメモリ消費量を 制限する
構文:RLimitMEM bytes|max [bytes|max]
デフォルト:未設定。オペレーティングシステムのデフォルトを使用
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Core
モジュール:core

一つか二つのパラメータをとります。 最初のパラメータは全プロセスに対するリソースのソフトリミットを設定し、 2 番目のパラメータは最大のリソースリミットを設定します。 パラメータには数字か、オペレーティングシステムの最大となる max のどちらかを指定することができます。 最大のリソースリミットを上げるためには、サーバを root で実行するか起動されなければいけません。

この設定は Apache の子プロセス自体ではなく、 リクエストを受け付けた Apache の子プロセスから fork されたプロセスに 適用されます。 これには CGI や SSI から実行されたコマンドが含まれますが、Apache の 親プロセスから fork されたログのパイププロセスなどには適用されません。

メモリリソースのリミットはプロセスあたりのバイト数で表わされます。

参照

top

RLimitNPROC ディレクティブ

説明:Apache の子プロセスから起動されたプロセスが起動するプロセスの 数を制限する
構文:RLimitNPROC number|max [number|max]
デフォルト:未設定。オペレーティングシステムのデフォルトを使用
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Core
モジュール:core

一つか二つのパラメータをとります。 最初のパラメータは全プロセスに対するリソースのソフトリミットを設定し、 2 番目のパラメータは最大のリソースリミットを設定します。 パラメータには数字か、オペレーティングシステムの最大となる max のどちらかを指定することができます。 最大のリソースリミットを上げるためには、サーバを root で実行するか起動されなければいけません。

この設定は Apache の子プロセス自体ではなく、 リクエストを受け付けた Apache の子プロセスから fork されたプロセスに 適用されます。 これには CGI や SSI から実行されたコマンドが含まれますが、Apache の 親プロセスから fork されたログのパイププロセスなどには適用されません。

プロセスの制限は、ユーザあたりのプロセス数で制御されます。

CGI プロセスがウェブサーバのユーザ ID 以外で実行されるので 無ければ、 このディレクティブは、サーバ自身が生成できるプロセスの数を制限することになります。 そのような状況になっているかどうかは、error_log 中の cannot fork というメッセージにより 確認することができます。

参照

top

Satisfy ディレクティブ

説明:ホストレベルのアクセス制御とユーザ認証との相互作用を指定
構文:Satisfy Any|All
デフォルト:Satisfy All
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Core
モジュール:core
互換性:バージョン 2.0.51 以降では <Limit> ディレクティブと <LimitExcept> ディレクティブの影響を受ける

AllowRequire の両方が使われているときの アクセスポリシーを設定します。パラメータは AllAny です。このディレクティブはある場所へのアクセスがユーザ名/パスワード クライアントのホストのアドレスで制限されているときにのみ 役立ちます。デフォルトの動作 (All) はクライアントがアドレスによる アクセス制限を満たし、かつ正しいユーザ名とパスワードを入力することを 要求します。Any では、クライアントはホストの制限を満たすか、 正しいユーザ名とパスワードの入力をするかをすればアクセスを許可されます。 これは、ある場所をパスワードで保護するけれど、特定のアドレスからの クライアントにはパスワードの入力を要求せずにアクセスを許可する、 というようなときに使用できます。

例えば、同じネットワーク上にいる人にはウェブサイトのある部分について 無制限のアクセスを許したいけれど、外のネットワークの人には パスワードを提供させるようにするためには、次のような設定をすることが できます:

Require valid-user
Order allow,deny
Allow from 192.168.1
Satisfy Any

バージョン 2.0.51 からは <Limit> セクションと <LimitExcept> セクションを使用することで Satisfy ディレクティブが 適用されるメソッドを制限することが できるようになりました。

参照

top

ScriptInterpreterSource ディレクティブ

説明:CGI スクリプトのインタープリタの位置を調べるための手法
構文:ScriptInterpreterSource Registry|Registry-Strict|Script
デフォルト:ScriptInterpreterSource Script
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Core
モジュール:core
互換性:Win32 のみ。 オプション Registry-Strict は Apache 2.0 以降で使用可能

このディレクティブは、Apache で CGI スクリプトを 実行する場合に利用するインタープリタを、 どのように探し出すかについて制御するために使用します。 デフォルトの設定は Script です。これはスクリプトの shebang 行 (最初の行で #! から始まるもの) に指されているインタープリタを使用します。Win32 ではその行は 以下の様になります。

#!C:/Perl/bin/perl.exe

もしくは、perlPATH にある場合は単に:

#!perl

ScriptInterpreterSource Registry を指定すると、 スクリプトファイルの拡張子 (例えば、.pl) を キーとして、Windows のレジストリツリー HKEY_CLASSES_ROOT を検索するようになります。レジストリのサブキー Shell\ExecCGI\Command か、それが存在しない場合は Shell\Open\Command がスクリプトファイルを開くために 使われます。レジストリキーが見つからないときは、Apache は Script オプションが指定されたときの動作に戻ります。

たとえば、レジストリの設定で .pl 拡張子が perl に関連付けられている:

HKEY_CLASSES_ROOT\.pl\Shell\ExecCGI\Command\(Default) => C:\Perl\bin\perl.exe -wT

セキュリティ

ScriptInterpreterSource RegistryScriptAlias されたディレクトリで使うときは 注意してください。Apache はそのディレクトリ中のすべてのファイルを 実行しようとします。Registry という設定は通常は実行されない ファイルに対して望ましくないプログラムの実行が発生する可能性があります。 例えば、ほとんどの Windows システムで、 .htm ファイルのデフォルトの「開く」コマンドは Microsoft Internet Explorer を実行しますので、スクリプトに指定された ディレクトリにある .htm ファイルへのリクエストはサーバの バックグラウンドでブラウザを実行することになります。これは、一分内くらいで システムをクラッシュさるための良い方法です。

Apache 2.0 から導入されたオプション Registry-StrictRegistry と同じことを行ないますが、サブキー Shell\ExecCGI\Command のみを使います。 ExecCGI キーは普通に使われるキーではありません。Windows レジストリに手動で設定する必要がありますので、システムでの偶発的なプログラムの 実行を防ぐことができます。

top

ServerAdmin ディレクティブ

説明:サーバがクライアントに送るエラーメッセージに含める電子メールの アドレス
構文:ServerAdmin email-address|URL
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core

ServerAdmin は、クライアントに返すさまざまな エラーメッセージ中に記述する、 問合せアドレスを設定します。与えられた引数を httpd が URL と認識しない場合は、email-address だと解釈して、 ハイパーリンクのターゲットに mailto: を付けます。 実際には、ここには電子メールアドレスを使うことが推奨されています。 多くの CGI スクリプトはそうなっていることを仮定しています。 URL を使う場合は、あなたの管理下にある別サーバを指すようにしてください。 そうでないと、エラーが起こったときに連絡をすることができなくなって しまいます。

その際、これのために専用のアドレスを設定するのが良いでしょう。 例えば、

ServerAdmin www-admin@foo.example.com

といったようにします。ユーザはいつもサーバに関する話であるということを 明記してくるわけではありませんので。

top

ServerAlias ディレクティブ

説明:リクエストを名前ベースのバーチャルホストにマッチさせているときに 使用されるホストの別名
構文:ServerAlias hostname [hostname] ...
コンテキスト:バーチャルホスト
ステータス:Core
モジュール:core

ServerAlias ディレクティブは、ネームベースのバーチャルホストにおいて 使用するホストの別名を指定します。ServerAlias は適切であればワイルドカードも含めることができます。

<VirtualHost *>
ServerName server.domain.com
ServerAlias server server2.domain.com server2
# ...
</VirtualHost>

参照

top

ServerName ディレクティブ

説明:サーバが自分自身を示すときに使うホスト名とポート
構文:ServerName [scheme://]fully-qualified-domain-name[:port]
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core
互換性:このディレクティブはバージョン 2.0 ではバージョン 1.3 の Port ディレクティブの機能も含みます。

ServerName ディレクティブは、 サーバが自分自身を示すリクエストスキームとホスト名とポートを設定します。 これは、リダイレクトする URL を生成する際に利用されます。 例えば、ウェブサーバを動かしているマシンは simple.example.com で、DNS のエイリアス www.example.com もあるときに、 ウェブサーバが後者として認識されて欲しいときは、以下のようにディレクティブを 使います。

ServerName www.example.com:80

ServerName が指定されていないときは、 サーバは IP アドレスから逆引きを行なうことでホスト名を知ろうとします。 ServerName にポートが指定されていないときは、 サーバはリクエストが来ている ポートを使います。最高の信頼性と確実性をもたらすためには、 ServerName を使ってホスト名とポートを明示的に 指定してください。

名前ベースのバーチャルホスト を利用している場合、<VirtualHost> セクション内の ServerName はこのバーチャルホストにマッチするために 何がリクエストの Host: ヘッダに現れる必要があるのかを指定します。

リバースプロキシやロードバランサやSSL負荷軽減装置のような、 SSLを処理するマシンの後ろでサーバを動かす場合は、 サーバが正しい自己参照 URLを確実に生成するように、 https:// スキームとクライアントが接続するポート番号を、 ServerName ディレクティブに指定してください。

自己参照 URL (例えば mod_dir モジュールによるものなど) が指定されたポートを使うか、クライアントのリクエストのポート番号を使うかを 決定する設定は UseCanonicalName ディレクティブと UseCanonicalPhysicalPort ディレクティブを参照してください。

参照

top

ServerPath ディレクティブ

説明:非互換のブラウザが名前ベースのバーチャルホストにアクセスしたときの ための互換用 URL パス名
構文:ServerPath URL-path
コンテキスト:バーチャルホスト
ステータス:Core
モジュール:core

ServerPath ディレクティブは、ネームベースのバーチャルホストにおいて利用する 互換用 URL パス名を設定します。

参照

top

ServerRoot ディレクティブ

説明:インストールされたサーバのベースディレクトリ
構文:ServerRoot directory-path
デフォルト:ServerRoot /usr/local/apache
コンテキスト:サーバ設定ファイル
ステータス:Core
モジュール:core

ServerRoot ディレクティブは、 サーバが存在するディレクトリを設定します。 通常、conf/logs/ といったサブディレクトリが 存在します。 また、他の設定ディレクティブ (例えば IncludeLoadModule など) における相対パスは、 このディレクトリからの相対位置となります。

ServerRoot /home/httpd

参照

top

ServerSignature ディレクティブ

説明:サーバが生成するドキュメントのフッタを設定
構文:ServerSignature On|Off|EMail
デフォルト:ServerSignature Off
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Core
モジュール:core

ServerSignature ディレクティブは、 サーバが生成するドキュメント (エラーメッセージ、mod_proxy における FTP のディレクトリリスト、 mod_info の出力、等々) の最下行に付与するフッタの設定を行ないます。 そのようなフッタ行を有効にしたい理由には、 プロキシが複数連なっている場合に、ユーザはどのサーバが返した エラーメッセージかを知る手段がほとんど無いというものがあります。

デフォルトである Off に設定をすると、フッタ行が抑制されます (そして、Apache-1.2 以前と互換の動作をします)。 On に設定した場合は、単にドキュメントの中に、サーバのバージョン、 稼動中のバーチャルホストの ServerName の書かれた行を追加し、 EMail にした場合はさらに参照されたドキュメントに対する ServerAdmin を指す "mailto:" が追加されます。

バージョン 2.0.44 以降ではこのディレクティブは ServerSignature ディレクティブにより表示される情報も制御します。

参照

top

ServerTokens ディレクティブ

説明:Server HTTP 応答ヘッダを設定する
構文:ServerTokens Major|Minor|Min[imal]|Prod[uctOnly]|OS|Full
デフォルト:ServerTokens Full
コンテキスト:サーバ設定ファイル
ステータス:Core
モジュール:core

このディレクティブは、クライアントに送り返す Server 応答ヘッダ内に、サーバの一般的な OS 種別や、 コンパイルされて組み込まれているモジュールの情報を 含めるかどうかを指定します。

ServerTokens Prod[uctOnly]
サーバは (例えば): Server: Apache といったように送ります。
ServerTokens Major
Server sends (e.g.): Server: Apache/2
ServerTokens Minor
Server sends (e.g.): Server: Apache/2.0
ServerTokens Min[imal]
サーバは (例えば): Server: Apache/2.0.41 といったように送ります。
ServerTokens OS
サーバは (例えば): Server: Apache/2.0.41 (Unix) といったように送ります。
ServerTokens Full (もしくは未指定)
サーバは (例えば): Server: Apache/2.0.41 (Unix) PHP/4.2.2 MyMod/1.2 といったように送ります。

この設定はサーバ全体に適用され、バーチャルホスト上で有効にしたり 無効にしたりはできません。

バージョン 2.0.44 以降ではこのディレクティブは ServerSignature ディレクティブにより表示される情報も制御します。

参照

top

SetHandler ディレクティブ

説明:マッチするファイルがハンドラで処理されるようにする
構文:SetHandler handler-name|None
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Core
モジュール:core
互換性:Apache 2.0 で core に移動

.htaccess<Directory> セクション、<Location> セクションに書かれた場合、 このディレクティブはそこにあるすべてのファイルが handler-name で指定されたハンドラで扱われることを強制します。例えば、拡張子に関わらず、 ディレクトリ全体がイメージマップファイルとして解析して欲しい場合には、 以下をそのディレクトリの .htaccess ファイルに記述します:

SetHandler imap-file

別の例: URL http://servername/status が指定されたときにサーバが状態報告をするようにしたいときは、以下を httpd.conf に記述します:

<Location /status>
SetHandler server-status
</Location>

None という値を設定することで、 前の方の SetHandler で定義された設定を無効にすることが できます。

注意:SetHandler はデフォルトのハンドラをオーバーライド しますので、通常の挙動、たとえば、スラッシュ (/) で終わる URL が リクエストされたときにディレクトリやインデックスファイルを返すよう取り扱う挙動は、 行われなくなります。

参照

top

SetInputFilter ディレクティブ

説明:クライアントのリクエストや POST の入力を処理するフィルタを設定する
構文:SetInputFilter filter[;filter...]
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Core
モジュール:core

SetInputFilter ディレクティブはクライアントの リクエストや POST の入力をサーバが受け取ったときに処理するフィルタを 設定します。これは AddInputFilter ディレクティブを含め、他の場所で定義されているフィルタの設定に 追加されます。

複数のフィルタを指定するときは、データを処理する順番に セミコロンで区切る必要があります。

参照

top

SetOutputFilter ディレクティブ

説明:サーバの応答を処理するフィルタを設定する
構文:SetOutputFilter filter[;filter...]
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Core
モジュール:core

SetOutputFilter ディレクティブは サーバの応答をクライアントに送り返される前に処理するフィルタを設定します。 これは AddOutputFilter ディレクティブを含め、他の場所で定義されているフィルタの設定に 追加されます。

例えば、以下の設定は /www/data/ ディレクトリのすべての ファイルを SSI で処理します。

<Directory /www/data/>
SetOutputFilter INCLUDES
</Directory>

複数のフィルタを指定するときは、データを処理する順番に セミコロンで区切る必要があります。

参照

top

TimeOut ディレクティブ

説明:各イベントについて、リクエストを失敗させるまでにサーバが 待つ時間を設定
構文:TimeOut seconds
デフォルト:TimeOut 300
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Core
モジュール:core

TimeOut ディレクティブは、現在のところ 以下の三つの待ち時間についての定義を行います:

  1. GET リクエストを受け取るのにかかる総時間
  2. POST や PUTリクエストにおいて、次の TCP パケットが届くまでの待ち時間
  3. レスポンスを返す際、TCP の ACK が帰ってくるまでの時間

将来には別々の設定をすることが可能にできるよう考慮中です。 Apache 1.2 以前はタイマーは 1200 がデフォルトでしたが、 300 に下げられました。300 でもほとんどの場合は十分すぎる値です。 コード中の変な場所にまだパケットを送る際にタイマをリセットしない 場所があるかもしれないので、デフォルトをより小さい値にはしていません。

top

TraceEnable ディレクティブ

説明:TRACE メソッドのリクエストに対する応答方法を決める
構文:TraceEnable [on|off|extended]
デフォルト:TraceEnable on
コンテキスト:サーバ設定ファイル
ステータス:Core
モジュール:core
互換性:Apache 1.3.34, 2.0.55 以降

コアサーバと mod_proxy 両方の TRACE の挙動をオーバーライドします。デフォルトの TraceEnable on は、リクエストボディを受け入れないような、RFC2616 に準拠した TRACE リクエストを受け付けます。 TraceEnale off と設定すると、コアサーバと mod_proxy405 (メソッド不許可) エラーをクライアントに返します。

最後に、テストや調査目的などの限定用途として、仕様に準拠しない TraceEnable extended を使って、リクエストボディを 受け付けるように挙動を変更できます。(オリジンサーバとしての) コアサーバでは、リクエストボディのサイズは 64k ( Transfer-Encoding: chunked が使われている場合は chunk ヘッダ用に +8k) に制限されます。 コアサーバは、フルヘッダと全ての chunk ヘッダをレスポンスの ボディとして返却します。 proxy サーバとしては、リクエストボディのサイズは 64k に制限されません。

top

UseCanonicalName ディレクティブ

説明:サーバが自分自身の名前とポートを決定する方法を設定する
構文:UseCanonicalName On|Off|Dns
デフォルト:UseCanonicalName Off
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ
ステータス:Core
モジュール:core

多くの状況で Apache は自己参照 URL、すなわち 同じサーバを指す URL、を作成する必要があります。 UseCanonicalName On の場合は、ServerName ディレクティブで指定されている ホスト名とポート番号を使って、その正規名 (自己参照の名前) を生成します。 この名前は、すべての自己参照 URL で使われますし、CGI の SERVER_NAMESERVER_PORT でも使われます。

UseCanonicalName Off の場合、 クライアントがホスト名とポートを指定したときには、 それらを元に自己参照 URL を作成します (指定がなかったときは 上の定義と同様にして正規名を解決します)。 これらの値は名前ベースの バーチャルホストを実装で使われているのと同じ値で、 同じクライアントで取得できる値になっています。 CGI 変数 SERVER_NAMESERVER_PORT もクライアントから与えられた値から作成されます。

このような挙動が便利な例は、イントラネットのサーバで www のような短い名前でユーザがマシンに接続するときです。 ユーザの入力で短いホスト名が使われていて、URL が最後のスラッシュ無しの ディレクトリになっている http://www/splat のようなとき、 Apache はリクエストを http://www.domain.com/splat/ へリダイレクトします。 認証をするように設定していると、この場合 ユーザは 2 回認証をしなければならなくなります (www に 対して 1 回、www.domain.com に対してもう 1 回 -- 詳細は この話題の FAQ を参照してください)。 しかし UseCanonicalNameOff になっていると、 Apache は http://www/splat/ にリダイレクトします。

三つ目のオプション UseCanonicalName DNS は、 大規模な IP ベースのバーチャルホスティングで、 Host: ヘッダを提供しない古いクライアントを サポートする場合を想定しています。 このオプションでは Apache は、クライアントが接続した IP アドレスに対して DNS の逆引きを行なって、自己参照 URL を作成します。

警告

CGI が SERVER_NAME に関して何らかの前提条件を 仮定しているときには、このオプションの設定によっては動作しなく なるかもしれません。クライアントは実質的にはホスト名として 何でも望みの値を指定することができます。CGI が SERVER_NAME を使って自己参照 URL を作成することしかしない 場合は、どの設定を行なっても大丈夫なはずです。

参照

top

UseCanonicalPhysicalPort ディレクティブ

説明:サーバの名前とポートの解決方法を設定する
構文:UseCanonicalPhysicalPort On|Off
デフォルト:UseCanonicalPhysicalPort Off
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ
ステータス:Core
モジュール:core

Apache は様々な状況で 自己参照 URL つまりサーバが自分自身を指し示す URL を生成する必要があります。 UseCanonicalName ディレクティブの 設定によってサーバの別名を構成するようになりますが、 その際の別名に使うポートは UseCanonicalPhysicalPort On という設定があれば、 実際のポート番号をポート番号として使う候補に入れてリクエストを 処理するようになります。UseCanonicalPhysicalPort Off という設定であれば、実際のポート番号は使用せず、設定されている情報を 全て信じてポート番号を構成するようになります。

実際のポート番号が使われる順序は次のようになっています :

UseCanonicalName On

  • ServerName で指定されているポート番号
  • 実際のポート番号
  • デフォルトのポート番号
UseCanonicalName Off | DNS
  • Host: ヘッダから抽出されたポート番号
  • 実際のポート番号
  • ServerName で指定されているポート番号
  • デフォルトのポート番号

UseCanonicalPhysicalPort Off で、 実際のポート番号が上の順序から取り除かれます。

参照

top

<VirtualHost> ディレクティブ

説明:特定のホスト名や IP アドレスのみに適用されるディレクティブを 囲む
構文:<VirtualHost addr[:port] [addr[:port]] ...> ... </VirtualHost>
コンテキスト:サーバ設定ファイル
ステータス:Core
モジュール:core

<VirtualHost> 及び </VirtualHost> は、 特定のバーチャルホストに対してのみ適用されるディレクティブ群を括る ために使われます。 バーチャルホストコンテキストで許可される全てのディレクティブを指定可能です。 サーバが、指定されたバーチャルホストにあるドキュメントへの リクエストを受け付けた場合、 <VirtualHost> セクションの中にある ディレクティブが適用されます。 Addrは、次のものが利用できます:

  • バーチャルホストの IP アドレス
  • バーチャルホストの IP に対応する完全なドメイン名(非推奨)
  • NameVirtualHost * と共に使われる、 すべての IP アドレスにマッチする文字 *
  • IP ベースのバーチャルホストで他のものにマッチしない IP アドレス のための文字列 _default_

<VirtualHost 10.1.2.3>
ServerAdmin webmaster@host.foo.com
DocumentRoot /www/docs/host.foo.com
ServerName host.foo.com
ErrorLog logs/host.foo.com-error_log
TransferLog logs/host.foo.com-access_log
</VirtualHost>

IPv6 アドレスはオプションのポート番号の指定と区別するために、 角括弧で括って指定する必要があります。次は IPv6 の例です:

<VirtualHost [2001:db8::a00:20ff:fea7:ccea]>
ServerAdmin webmaster@host.example.com
DocumentRoot /www/docs/host.example.com
ServerName host.example.com
ErrorLog logs/host.example.com-error_log
TransferLog logs/host.example.com-access_log
</VirtualHost>

各々のバーチャルホストにはそれぞれ違う IP アドレス、ポート番号 もしくはホスト名に対応する必要があり、 1 番目の場合には複数のアドレスで IP パケットを受信できるように サーバマシンを設定しなければなりません。 (もし、マシンが複数のネットワークインターフェースと持たない場合は、 (OSがサポートしていれば) ifconfig alias コマンドにより 達成できます)。

注意点

<VirtualHost> は Apache が Listen する IP アドレスには影響を与えませんListen を 使って Apache が正しいアドレスを listen するように設定する必要があります。

IP ベースのバーチャルホストを使っている場合は、特別な名前 _default_ を指定することができます。その場合は そのバーチャルホストは他のバーチャルホストで明示的に挙げられていない すべての IP アドレスにマッチします。_default_ バーチャルホストが無い 場合に IP がバーチャルホストで指定されたものにマッチしないときは、 VirtualHost セクションの外のすべての定義からなる「主」サーバ設定が 使われます。(ただし、NameVirtualHost ディレクティブにマッチする すべての IP アドレスは「主」サーバ設定も _default_ バーチャルホストも 使わないことに注意してください。詳しくは ネームベースのバーチャルホスト を 参照してください。)

:port といった形式で記述することにより、 マッチさせるポートを変更可能です。 この指定をしない場合には、主サーバ設定における 一番最後に Port で指定されたポートが デフォルトとなります。 :* を指定することにより、 アドレス上の全てのポートにマッチします。(_default_ のときは これを使うことが推奨されています。)

それぞれの <VirtualHost> ブロック内で ServerName を指定します。もしこれが無いと、"main" サーバ設定の ServerName が引き継がれます。

セキュリティ

サーバーを起動した以外のユーザがログファイルが保管されるディレクトリに 書き込み可能なときになぜセキュリティが破られる可能性があるかの詳細は セキュリティに関するコツ を 参照してください。

参照

mod/directive-dict.html100644 0 0 40322 11237400230 12562 0ustar 0 0 ディレクティブの解説に使われる用語 - Apache HTTP サーバ
<-

ディレクティブの解説に使われる用語

この文書は各 Apache 設定ディレクティブ を説明するために使われている用語を説明します。

top

説明

ディレクティブの目的の簡単な説明。

top

構文

設定ファイル中のディレクティブの書式を示します。 この構文はディレクティブ特有なので、詳細はディレクティブの説明を 参照してください。一般的に、ディレクティブ名の後には 空白により分割されたいくつかの引数が続きます。 引数が空白を含むときは二重引用符 (訳注: ") で囲まれています。 オプショナルな引数は括弧 (訳注: []) で囲まれています。 引数が複数の値を取り得る場合は、それらの値は垂直の棒 "|" で 分割されています。 変更されないテキストはデフォルトのフォントで表示され、置換の必要な 引数は強調されて表示されます。 引数の数が変わるディレクティブは最後の 引数が繰り返されることを示すために "..." で終わります。

ディレクティブは多くの違う型の引数をとります。いくつか、良く 使われるものを以下で定義します。

URL
http://www.example.com/path/to/file.html のように、 スキーム、ホスト名、パス名(省略可能)を含んでいる完全な Uniform Resource Locator。
URL-path
/path/to/file.html のように、スキームと ホスト名の後に続く url の一部。url-path は ファイルシステムからの視点ではなく、 ウェブからの視点でリソースを表現します。
file-path
/usr/local/apache/htdocs/path/to/file.html のように、 ルートディレクトリから始まるローカルのファイルシステム上のファイルへのパス。 通常、スラッシュで始まらない file-pathServerRoot からの相対パスとして 扱われます。
directory-path
/usr/local/apache/htdocs/path/to/ のように、 ルートディレクトリから始まるローカルのファイルシステムのディレクトリへの パス。
filename
file.html のように、パス情報の付いていない ファイル名。
regex
Perl 互換の正規表現です。 ディレクティブの定義が regex が何に対してマッチを行なうのかを指定します。
extension
一般的には filename の最後のドットの後の部分です。 しかし、Apache は複数のファイルの拡張子を認識しますので、filename に複数のドットがあると、最初のドットの後の、それぞれのドットで分離された部分が extension (訳注: 拡張子) になります。例えば、filename file.html.en には二つの拡張子があります。.html.en です。Apache のディレクティブでは、extension はドット付きでも無しでも指定できます。さらに、extension は 大文字小文字を区別しません。
MIME-type
text/html のように、スラッシュで分離された 主フォーマットと副フォーマットによってファイルの形式を 表す方法です。
env-variable
Apache の設定により定義される 環境変数の名前です。これはオペレーティングシステムの 環境変数と同じとは限らないことに注意してください。詳細は 環境変数の説明を参照してください。
top

デフォルト

ディレクティブにデフォルト値 (すなわち、設定ファイルから 省略されていても、Apache ウェブサーバは特定の値に設定されているかのように 動作します) がある場合はここに記述されます。 デフォルト値の無い場合、ここは "None" と 書かれます。ここで書かれているデフォルトはサーバと共に配布されている デフォルトの httpd.conf 内に書かれているディレクティブの値と 違う可能性があることに注意してください。

top

コンテキスト

これは、サーバの設定ファイル中のどこでディレクティブが有効なのかを示します。 次に示す値が一つ以上カンマ区切りで列挙されています。

サーバ設定ファイル
これは、サーバ設定ファイル (例えばhttpd.conf, srm.conf, access.conf) 内では使用できますが、 <VirtualHost><Directory> の中では 使用できないことを示します。 .htaccessファイルでの使用は許可されていません。
バーチャルホスト
これは、サーバ設定ファイルの <VirtualHost> の中で使用できることを示します。
ディレクトリ
これは、サーバ設定ファイルの <Directory>, <Location>, <Files>, <Proxy> コンテナの中で、 設定セクション で説明されている制限の下で使用できることを示します。
.htaccess
これは、ディレクトリ.htaccess ファイル内で 使用可能であることを示します。 ただ、上書き の設定によっては、処理されないかもしれません。

ディレクティブは指示されたコンテキストでのみ許可されます。 他の場所で使おうとすると、サーバがそのコンテキストを正しく扱えなく なるような設定エラーが発生するか、サーバがまったく動作しなくなる、 すなわち、サーバが起動しなくなるということになります。

ディレクティブの有効な位置は、実際は挙げられているコンテキストの 論理和 (訳注: Boolen OR) になります。言い換えると、 "サーバ設定ファイル、.htaccess" で有効だと 記されているディレクティブは httpd.conf ファイルと .htaccess ファイルとで有効ですが、 <Directory><VirtualHost> の中では使用できません。

top

上書き

このディレクティブの属性は、.htaccess ファイル中に ディレクティブが現れたときに、それの処理を有効にするために どの設定の上書きが必要かを示します。 ディレクティブの コンテキスト が、.htaccess ファイル中では許可していない場合は、 この属性は "適用不可" と書かれます。

上書きは、AllowOverride ディレクティブによって有効にされ、 特定のスコープ(ディレクトリなど)と、 さらに下位のレベルの AllowOverride で修正されない限り、 その配下に対して適用されます。 ディレクティブのドキュメントは取り得る上書きの名前も挙げます。

top

ステータス

これはディレクティブが Apache ウェブサーバにどれくらいきつく組み込まれているかを 示します。言い換えれば、ディレクティブとその機能を利用するために、 モジュールの数を増やして、サーバを再コンパイルする必要があるかもしれない ということを示します。 この属性が取り得る値は以下のものです:

Core
"Core" のディレクティブは Apache ウェブサーバの基本となるべきものであり、 常に使用可能であることを示します。
MPM
"MPM" のディレクティブはマルチプロセッシングモジュールで提供されています。 この種類のディレクティブはディレクティブの定義のモジュールの行に使っているモジュールの名前が書かれている 場合にのみ使用可能です。
Base
"Base" のディレクティブは デフォルトでサーバに組み込まれている標準モジュールの中の一つでサ ポートされていて、わざわざ設定からモジュールを削除したときを除いて、 通常では使用可能であることを示します。
Extension
"Extension" のディレクティブは、 Apache サーバの配布物に同梱されているモジュールの一つで提供されているものの、 通常ではサーバに組み込まれていないことを示します。 ディレクティブとその機能を有効にするには、サーバビルド用の設定ファイルを 変更して Apache を再コンパイルする必要があります。
Experimental
"Experimental" のディレクティブは、Apache 配布物に 同梱されているものの、試したい場合は自己責任で行なう 必要があるということを示します。ディレクティブは、すべてのドキュメントを 完全にそろわせるために解説されていますが、サポートされているとは限りません。 ディレクティブを提供するモジュールはデフォルトで組み込まれているかも しれませんし、そうでないかもしれません。使用可能かどうかは、 ディレクティブとモジュールの説明をしているページの先頭を調べてください。
top

モジュール

これは単純にディレクティブが定義されているモジュールの名前を記載します。

top

互換性

ディレクティブが Apache 2 の配布に組み込まれていなかった場合、 ディレクティブが導入されたバージョンがここに書かれています。 また、ディレクティブが特定のプラットフォームにのみ存在するときも ここに書かれています。

mod/directives.html100644 0 0 72751 11237400230 12037 0ustar 0 0 ディレクティブ一覧 - Apache HTTP サーバ
<-

ディレクティブ一覧

標準 Apache 配布にあるすべての Apache のディレクティブの一覧です。 これらは一貫した形式で書かれていて、使われている用語の 用語集 も用意されています。

各ディレクティブの概要を説明した ディレクティブクイックリファレンスも あります。

 A  |  B  |  C  |  D  |  E  |  F  |  G  |  H  |  I  |  K  |  L  |  M  |  N  |  O  |  P  |  R  |  S  |  T  |  U  |  V  |  W  |  X 

mod/event.html100644 0 0 21443 11237400230 11007 0ustar 0 0 event - Apache HTTP Server
<-

Apache MPM event

Description:An experimental variant of the standard worker MPM
Status:MPM
ModuleIdentifier:mpm_event_module
SourceFile:event.c

Summary

Warning

This MPM is experimental, so it may or may not work as expected.

The event Multi-Processing Module (MPM) is designed to allow more requests to be served simultaneously by passing off some processing work to supporting threads, freeing up the main threads to work on new requests. It is based on the worker MPM, which implements a hybrid multi-process multi-threaded server. Run-time configuration directives are identical to those provided by worker.

To use the event MPM, add --with-mpm=event to the configure script's arguments when building the httpd.

top

How it Works

This MPM tries to fix the 'keep alive problem' in HTTP. After a client completes the first request, the client can keep the connection open, and send further requests using the same socket. This can save signifigant overhead in creating TCP connections. However, Apache traditionally keeps an entire child process/thread waiting for data from the client, which brings its own disadvantages. To solve this problem, this MPM uses a dedicated thread to handle both the Listening sockets, and all sockets that are in a Keep Alive state.

The MPM assumes that the underlying apr_pollset implementation is reasonably threadsafe. This enables the MPM to avoid excessive high level locking, or having to wake up the listener thread in order to send it a keep-alive socket. This is currently only compatible with KQueue and EPoll.

top

Requirements

This MPM depends on APR's atomic compare-and-swap operations for thread synchronization. If you are compiling for an x86 target and you don't need to support 386s, or you are compiling for a SPARC and you don't need to run on pre-UltraSPARC chips, add --enable-nonportable-atomics=yes to the configure script's arguments. This will cause APR to implement atomic operations using efficient opcodes not available in older CPUs.

This MPM does not perform well on older platforms which lack good threading, but the requirement for EPoll or KQueue makes this moot.

  • To use this MPM on FreeBSD, FreeBSD 5.3 or higher is recommended. However, it is possible to run this MPM on FreeBSD 5.2.1, if you use libkse (see man libmap.conf).
  • For NetBSD, at least version 2.0 is recommended.
  • For Linux, a 2.6 kernel is recommended. It is also necessary to ensure that your version of glibc has been compiled with support for EPoll.
top

Issues

At present, this MPM is incompatible with mod_ssl, and other input filters.

mod/index.html100644 0 0 35454 11237400230 11004 0ustar 0 0 モジュール一覧 - Apache HTTP サーバ
<-

モジュール一覧

以下は Apache の配布の一部として配られているすべてのモジュールの 一覧です。すべての Apache ディレクティブ のアルファベット順のリストも見てください。

top

コア機能と MPM

core
常に使用可能な Apache HTTP サーバのコア機能
mpm_common
二つ以上のマルチプロセッシングモジュール (MPM) で実装されているディレクティブのコレクション
beos
This Multi-Processing Module is optimized for BeOS.
event
An experimental variant of the standard worker MPM
mpm_netware
Multi-Processing Module implementing an exclusively threaded web server optimized for Novell NetWare
mpmt_os2
Hybrid multi-process, multi-threaded MPM for OS/2
prefork
スレッドを使わず、先行して fork を行なうウェブサーバを実装
mpm_winnt
Windows NT 向けに最適化されたマルチプロセッシングモジュール
worker
マルチスレッドとマルチプロセスのハイブリッド型 ウェブサーバを実装したマルチプロセッシングモジュール
top

他のモジュール

 A  |  C  |  D  |  E  |  F  |  H  |  I  |  L  |  M  |  N  |  P  |  R  |  S  |  U  |  V 

mod_actions
メディアタイプやリクエストメソッドに応じて CGI スクリプトを実行する機能を提供
mod_alias
ホストファイルシステム上のいろいろな違う場所を ドキュメントツリーにマップする機能と、 URL のリダイレクトを行なう機能を提供する
mod_asis
自分用の HTTP ヘッダの書かれているファイルを送信する
mod_auth_basic
基本認証
mod_auth_digest
User authentication using MD5 Digest Authentication.
mod_authn_alias
Provides the ability to create extended authentication providers based on actual providers
mod_authn_anon
認証が必要な領域への "anonymous" ユーザのアクセスを許可する
mod_authn_dbd
User authentication using an SQL database
mod_authn_dbm
DBM ファイルを用いたユーザ認証
mod_authn_default
認証フォールバックモジュール
mod_authn_file
テキストファイルを用いたユーザ認証
mod_authnz_ldap
Allows an LDAP directory to be used to store the database for HTTP Basic authentication.
mod_authz_dbm
Group authorization using DBM files
mod_authz_default
承認フォールバックモジュール
mod_authz_groupfile
プレーンテキストファイルを用いたグループ承認
mod_authz_host
ホスト (名前もしくは IP アドレス) に基づいたグループ承認
mod_authz_owner
ファイルの所有者に基づいた承認
mod_authz_user
ユーザ承認
mod_autoindex
Unix の ls コマンドや Win32 の dir シェルコマンドに似た ディレクトリインデックスを生成する
mod_cache
URI をキーにしたコンテンツのキャッシュ
mod_cern_meta
CERN httpd metafile semantics
mod_cgi
CGI スクリプトの実行
mod_cgid
外部 CGI デーモンを使った CGI スクリプトの実行
mod_charset_lite
Specify character set translation or recoding
mod_dav
分散オーサリングとバージョン管理 (WebDAV) 機能
mod_dav_fs
mod_dav のためのファイルシステムプロバイダ
mod_dav_lock
mod_dav 用の汎用ロックモジュール
mod_dbd
Manages SQL database connections
mod_deflate
クライアントへ送られる前にコンテンツを圧縮する
mod_dir
「最後のスラッシュ」のリダイレクトと、ディレクトリの インデックスファイルを扱う機能を提供する
mod_disk_cache
URI をキーにしたコンテンツキャッシュストレージ管理
mod_dumpio
望むようにすべての I/O をエラーログにダンプする
mod_echo
プロトコルモジュールの概要を示すための単純なエコーサーバ
mod_env
CGI スクリプト及び SSI ページに渡される環境変数を変更する機能を提供する
mod_example
Illustrates the Apache module API
mod_expires
ユーザの指定した基準に基づいた ExpiresCache-Control HTTP ヘッダの生成
mod_ext_filter
レスポンスのボディをクライアントに送る前に外部プログラムで処理する
mod_file_cache
Caches a static list of files in memory
mod_filter
Context-sensitive smart filter configuration module
mod_headers
HTTP リクエストのヘッダと応答のヘッダのカスタマイズ
mod_ident
RFC 1413 ident lookups
mod_imagemap
Server-side imagemap processing
mod_include
サーバがパースする html ドキュメント (Server Side Includes)
mod_info
サーバの設定の包括的な概観を提供する
mod_isapi
ISAPI Extensions within Apache for Windows
mod_ldap
LDAP connection pooling and result caching services for use by other LDAP modules
mod_log_config
サーバへのリクエストのロギング
mod_log_forensic
サーバに送られたリクエストの forensic ロギング
mod_logio
リクエスト毎に入力バイト数と出力バイト数とをロギング
mod_mem_cache
URI をキーにしたコンテンツのキャッシュ
mod_mime
リクエストされたファイルの拡張子とファイルの振る舞い (ハンドラとフィルタ)、内容 (MIME タイプ、言語、文字セット、エンコーディング) とを関連付ける
mod_mime_magic
Determines the MIME type of a file by looking at a few bytes of its contents
mod_negotiation
コンテントネゴシエーション 機能を提供する
mod_nw_ssl
Enable SSL encryption for NetWare
mod_proxy
HTTP/1.1 プロキシ/ゲートウェイサーバ
mod_proxy_ajp
mod_proxy で AJP をサポートするためのモジュール
mod_proxy_balancer
負荷分散のための mod_proxy 拡張
mod_proxy_connect
CONNECT リクエストを扱う mod_proxy 用の拡張
mod_proxy_ftp
FTP support module for mod_proxy
mod_proxy_http
HTTP support module for mod_proxy
mod_rewrite
Provides a rule-based rewriting engine to rewrite requested URLs on the fly
mod_setenvif
リクエストの特徴に基づいた環境変数の設定を可能にする
mod_so
起動時や再起動時に実行コードとモジュールをサーバにロードする
mod_speling
ユーザが入力したであろう間違った URL を、 大文字小文字の区別を無視することと一つ以下の綴り間違いを許容することで 修正を試みる
mod_ssl
Strong cryptography using the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols
mod_status
サーバの活動状況と性能に関する情報を提供する
mod_substitute
Perform search and replace operations on response bodies
mod_suexec
指定されたユーザとグループで CGI スクリプトを実行する
mod_unique_id
それぞれのリクエストに対する一意な識別子の入った環境変数を 提供する
mod_userdir
ユーザ専用のディレクトリを提供
mod_usertrack
Clickstream logging of user activity on a site
mod_version
バージョン依存の設定
mod_vhost_alias
Provides for dynamically configured mass virtual hosting
mod/mod_actions.html100644 0 0 24314 11237400230 12165 0ustar 0 0 mod_actions - Apache HTTP サーバ
<-

Apache モジュール mod_actions

説明:メディアタイプやリクエストメソッドに応じて CGI スクリプトを実行する機能を提供
ステータス:Base
モジュール識別子:actions_module
ソースファイル:mod_actions.c

概要

このモジュールには二つのディレクティブがあります。Action ディレクティブは特定の MIME タイプ のファイルをリクエストされた場合に CGI スクリプトが実行されるようにします。Script ディレクティブはリクエストで特定のメソッドが使用されたときに CGI スクリプトが実行されるようにします。 これはファイルを処理するスクリプトの実行をずっと簡単にします。

top

Action ディレクティブ

説明:特定のハンドラやコンテントタイプに対して CGI を実行するように 設定
構文:Action action-type cgi-script [virtual]
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_actions
互換性:virtual 修飾子とハンドラ渡しは Apache 2.1 で導入されました

このディレクティブは action-type がリクエストされたときに cgi-script が実行されるという動作を追加します。cgi-scriptScriptAliasAddHandler によって CGI スクリプトに設定されたリソースへの URL-path です。 Action-type には handlerMIME コンテントタイプを指定できます。リクエストされたドキュメントの URL とファイルのパスは標準 CGI 環境変数 PATH_INFOPATH_TRANSLATED を使って伝えられます。 特定のリクエストに対して使用されるハンドラへは、 REDIRECT_HANDLER 変数を使って渡せます。

# Requests for files of a particular MIME content type:
Action image/gif /cgi-bin/images.cgi

# Files of a particular file extension
AddHandler my-file-type .xyz
Action my-file-type /cgi-bin/program.cgi

最初の例では、MIME コンテントタイプが image/gif のファイルへのリクエストは、指定したスクリプト /cgi-bin/images.cgi で処理されます。

2 番目の例では、拡張子が .xyz のファイルへのリクエストは、指定したスクリプト /cgi-bin/program.cgi で処理されます。

オプションの virtual 修飾子を使用すると、 リクエストされたファイルが実際に存在するかどうかを検査しないようにできます。 これは例えば、Action ディレクティブをバーチャルな Location に使用したい、といった場合に便利です。

<Location /news>
SetHandler news-handler
Action news-handler /cgi-bin/news.cgi virtual
</Location>

参照

top

Script ディレクティブ

説明:特定のリクエストメソッドに対して CGI スクリプトを 実行するように設定
構文:Script method cgi-script
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ
ステータス:Base
モジュール:mod_actions

このディレクティブは method というメソッドを使ってリクエストが行なわれたときに cgi-script を実行するという動作を追加します。 cgi-scriptScriptAliasAddHandler によって CGI スクリプトに設定されたリソースへの URL-path です。 リクエストされたドキュメントの URL とファイルのパスは標準 CGI 環境変数 PATH_INFOPATH_TRANSLATED を使って伝えられます。

任意のメソッド名を使用することができます。 メソッド名は大文字小文字を区別します。ですから、 Script PUTScript put はまったく違った効果になります。

Script コマンドはデフォルトの動作を 追加するだけであることに 注意してください。もし CGI スクリプトが呼ばれたり、リクエストされた メソッドを内部で扱うことのできる他のリソースがあれば、それが行なわれます。 GET メソッドの Script は問合せ 引数がある場合にのみ (たとえば、foo.html?hi) 呼ばれるということにも注意してください。 そうでない場合は、リクエストは通常通り処理されます。

# For <ISINDEX>-style searching
Script GET /cgi-bin/search

# A CGI PUT handler
Script PUT /~bob/put.cgi

mod/mod_alias.html100644 0 0 63147 11237400230 11625 0ustar 0 0 mod_alias - Apache HTTP サーバ
<-

Apache モジュール mod_alias

This translation may be out of date. Check the English version for recent changes.
説明:ホストファイルシステム上のいろいろな違う場所を ドキュメントツリーにマップする機能と、 URL のリダイレクトを行なう機能を提供する
ステータス:Base
モジュール識別子:alias_module
ソースファイル:mod_alias.c

概要

このモジュールのディレクティブはサーバにリクエストが到着したときに URL の操作や制御をすることを可能にします。Alias ディレクティブと ScriptAlias ディレクティブは URL とファイルシステムのパスをマップするために使用されます。これは DocumentRoot の下にないドキュメントをウェブのドキュメントツリーの一部として 送られるようにします。ScriptAlias ディレクティブにはマップ先のディレクトリが CGI スクリプトのみであることを示すという追加の効果があります。

Redirect ディレクティブは クライアントに違った URL に新しいリクエストを送るように指示します。これは、 リソースが新しい場所に移動したときによく使用されます。

mod_alias は簡単な URL 操作向けに設計されています。 より複雑な操作、クエリーストリングの操作には、mod_rewrite で提供されるツールを使用してください。

top

処理の順番

様々なコンテキスト中での Alias や Redirect は他のディレクティブと 同じように標準の マージ規則 に 従って処理されます。ただし、(例えば <VirtualHost> セクションの中のように) 複数の Alias や Redirect が 同じコンテキスト中に現れた場合は決まった順番で処理されます。

まず、Alias の前にすべての Redirect が処理されます。ですから、RedirectRedirectMatch にマッチするリクエストには Alias は決して適用されません。次に、Alias と Redirect が設定ファイル中の 順番に適用され、最初にマッチしたものが優先されます。

ですから、二つ以上のディレクティブが同じパスに適用されるときは、 すべてのディレクティブの効果を得るためにはより詳しいパスを先に書く 必要があります。例えば、次の設定は期待通りの動作をします:

Alias /foo/bar /baz
Alias /foo /gaq

しかし、上記の二つのディレクティブの順番が逆になると、 /foo Alias が 常に /foo/bar Alias より先にマッチしますので、後者は 決して適用されることはありません。

top

Alias ディレクティブ

説明:URL をファイルシステムの位置にマップする
構文:Alias URL-path file-path|directory-path
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Base
モジュール:mod_alias

Alias ディレクティブはドキュメントを ローカルファイルシステムの DocumentRoot 以外の場所に保管することを可能にします。 URL の (% が復号された) パスが url-path で始まるものは directory-filename で始まるローカルファイルにマップされます。

Alias /image /ftp/pub/image

http://myserver/image/foo.gif へのリクエストに対して、サーバは ファイル /ftp/pub/image/foo.gif を返します。完全なパスセグメントが 一致した時にのみ働きますので、上の例は http://myserver/imagefoo.gif に対するリクエストにはマッチしません。正規表現を使ったより複雑な マッチングに関しては AliasMatch ディレクティブをご覧ください。

もし url-path の最後に / を書いたなら、サーバがエイリアスを展開するためには、最後の / が必要になることに注意してください。すなわち、Alias /icons/ /usr/local/apache/icons/ というものを使用している場合は、 /icons という url はエイリアスされません。

エイリアスの行き先を含んでいる <Directory> セクションを追加する必要があるかもしれないことに注意してください。 エイリアスの展開は <Directory> セクションを調べる前に行なわれますので、 エイリアスの行き先の <Directory> セクションのみ 効果があります。 (しかし、<Location> セクションはエイリアスが処理される前に実行されますので、 こちらは適用されます。)

特に、AliasDocumentRoot ディレクトリの外側に配置した場合は、行き先のディレクトリに対する アクセス権限を明示的に制限しなければならないでしょう。

Alias /image /ftp/pub/image
<Directory /ftp/pub/image>
Order allow,deny
Allow from all
</Directory>

top

AliasMatch ディレクティブ

説明:正規表現を使って URL をファイルシステムの位置にマップする
構文:AliasMatch regex file-path|directory-path
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Base
モジュール:mod_alias

このディレクティブは Alias とほとんど同じですが、簡単な先頭からのマッチを行なうのではなく、 正規表現を利用します。 ここで指定された正規表現と URL のパス が合うかどうかを調べ、合う場合は括弧で括られたマッチを 与えられた文字列で置き換え、それをファイル名として使用します。たとえば、 /icons ディレクトリを使う ためには以下のようなものが使用できます:

AliasMatch ^/icons(.*) /usr/local/apache/icons$1

top

Redirect ディレクティブ

説明:クライアントが違う URL を取得するように外部へのリダイレクトを 送る
構文:Redirect [status] URL-path URL
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_alias

Redirect ディレクティブは古い URL を新しいものへマップして、 クライアントに新しい場所を訪れるように指し示します。

古い URL-path (% が復号された) パスは、 スラッシュで始まるものです。相対パスは使用できません。 新しい URL は絶対 URL 、つまりスキームとホスト名で 始まるものであるべきですが、URL-path の、スラッシュで始まるものも 使用可能です。その場合は、現在のスキームとホスト名が追加されたことに なります。

URL-Path で始まるどんなリクエストも、ターゲットの URL へとリダイレクトが返されます。URL-Path にマッチした path 情報は、ターゲット URL の後ろに追加された 形で引き継がれます。

Redirect /service http://foo2.example.com/service

クライアントは http://example.com/service/foo.txt へのリクエストを行なうと、代わりに http://foo2.example.com/service/foo.txt をアクセスするように告げられます。 パスセグメントが完全に一致したもののみがマッチしますので、 上記の例は http://example.com/servicefoo.txt にはマッチしません。 正規表現を使ったより複雑なマッチングについては、 RedirectMatch ディレクティブをご覧ください。

注意

設定ファイル中の順番に関わらず、 Redirect 系のディレクティブは Alias ディレクティブと ScriptAlias ディレクティブよりも優先されます。

もし status 引数が与えられていなければ、リダイレクトは "temporary" (HTTP ステータス 302) になります。これはクライアントに リソースが一時的に移動したということを示します。Status 引数は 他の HTTP のステータスコードを返すために使用することができます:

permanent
永久にリダイレクトをするステータス (301) を返します。 これはリソースが永久に移動したということを意味します。
temp
一時的なリダイレクトステータス (302) を返します。これがデフォルトです。
seeother
"See Other" ステータス (303) を返します。 これはリソースが他のもので置き換えられたことを意味します。
gone
"Gone" ステータス (410) を返します。これはリソースが永久に 削除されたことを意味します。このステータスが使用された場合、 url 引数は省略されなければなりません。

Status の値にステータスコードを数値で与えることで 他のステータスコードも返すことができます。ステータスが 300 と 399 の間にある場合、url 引数は存在していなければいけません。 その他の場合は省略されていなければなりません。ただし、 ステータスは Apache のコードが知っているものである必要があります (http_protocol.c の関数 send_error_response を見てください)。

例:

Redirect permanent /one http://example.com/two
Redirect 303 /three http://example.com/other

top

RedirectMatch ディレクティブ

説明:現在の URL への正規表現のマッチにより 外部へのリダイレクトを送る
構文:RedirectMatch [status] regex URL
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_alias

このディレクティブは Redirect とほとんど同じですが、簡単な先頭からのマッチを行なうのではなく、 正規表現を利用します。 ここで指定された正規表現と URL-path が合うかどうかを調べ、合う場合は括弧で括られたマッチを 与えられた文字列で置き換え、それをファイル名として使用します。 たとえば、すべての GIF ファイルを別サーバの同様な名前の JPEG ファイルにリダイレクトするには、以下のようなものを使います:

RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg

top

RedirectPermanent ディレクティブ

説明:クライアントが違う URL を取得するように外部への永久的な リダイレクトを送る
構文:RedirectPermanent URL-path URL
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_alias

このディレクティブはクライアントに Redirect が永久的なもの (ステータス 301) であることを知らせます。 Redirect permanent とまったく同じです。

top

RedirectTemp ディレクティブ

説明:クライアントが違う URL を取得するように外部への一時的な リダイレクトを送る
構文:RedirectTemp URL-path URL
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_alias

このディレクティブはクライアントに Redirect が一時的なものである (ステータス 302) ことを知らせます。 Redirect temp とまったく同じです。

top

ScriptAlias ディレクティブ

説明:URL をファイルシステムの位置へマップし、マップ先を CGI スクリプトに指定
構文:ScriptAlias URL-path file-path|directory-path
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Base
モジュール:mod_alias

ScriptAlias ディレクティブは、対象ディレクトリに mod_cgi の cgi-script ハンドラで処理される CGI スクリプトがあることを示す以外は Alias ディレクティブと同じ振る舞いをします。 URL の (% が復号された) パスが URL-path で始まるものは ローカルのファイルシステムの フルパスである二番目の引数にマップされます。

ScriptAlias /cgi-bin/ /web/cgi-bin/

http://myserver/cgi-bin/foo へのリクエストに対してサーバはスクリプト /web/cgi-bin/foo を実行します。

top

ScriptAliasMatch ディレクティブ

説明:URL を正規表現を使ってファイルシステムの位置へマップし、マップ先を CGI スクリプトに指定
構文:ScriptAliasMatch regex file-path|directory-path
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Base
モジュール:mod_alias

このディレクティブは ScriptAlias とほとんど同じですが、簡単な先頭からのマッチを行なうのではなく、 正規表現を利用します。ここで指定された正規表現と URL-path が合うかどうかを調べ、合う場合は括弧で括られたマッチを 与えられた文字列で置き換え、それをファイル名として使用します。 たとえば、標準の /cgi-bin を使用するようにするためには、以下のようなものを使います:

ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1

mod/mod_asis.html100644 0 0 13312 11237400230 11460 0ustar 0 0 mod_asis - Apache HTTP サーバ
<-

Apache モジュール mod_asis

説明:自分用の HTTP ヘッダの書かれているファイルを送信する
ステータス:Base
モジュール識別子:asis_module
ソースファイル:mod_asis.c

概要

このモジュールはハンドラ send-as-is を提供します。このハンドラは通常の HTTP ヘッダをほとんど追加することなくドキュメントを送信します。

これはサーバからどんな種類のデータを送るときにも使用できます。 Cgi スクリプトや nph スクリプトが無くてもリダイレクトや他の特別な HTTP 応答を送ることができます。

歴史的な理由により、このモジュールは mime タイプ httpd/send-as-is のファイルも処理します。

ディレクティブ

このモジュールにディレクティブはありません。

トピック

参照

top

使用法

サーバ設定ファイルで、ファイルと send-as-is ハンドラを例えば以下のように関連付けてください。

AddHandler send-as-is asis

拡張子が .asis のすべてのファイルの内容は Apache からクライアントへほとんど変更無く送られます。 特に、HTTP ヘッダはファイルそれ自体から mod_cgi と同じ規則で読み取られますので、asis ファイルには適切なヘッダが 含まれていなければなりませんし、CGI での Status: ヘッダを 書いて HTTP レスポンスコードを決めることもできます。

これはクライアントにファイルが移動したことを知らせるために as is (そのまま) で送られるファイルの内容の例です。

Status: 301 Now where did I leave that URL
Location: http://xyz.abc.com/foo/bar.html
Content-type: text/html

<html>
<head>
<title>Lame excuses'R'us</title>
</head>
<body>
<h1>Fred's exceptionally wonderful page has moved to
<a href="http://xyz.abc.com/foo/bar.html">Joe's</a> site.
</h1>
</body>
</html>

注意

注意: サーバはクライアントに返されるデータに常に Date:Server: ヘッダを追加しますので、 それらがファイルに書かれていてはいけません。 サーバは Last-Modified ヘッダを追加しません。 おそらくはそうすべきでしょうけれど。

mod/mod_auth_basic.html100644 0 0 21052 11237400230 12623 0ustar 0 0 mod_auth_basic - Apache HTTP サーバ
<-

Apache モジュール mod_auth_basic

This translation may be out of date. Check the English version for recent changes.
説明:基本認証
ステータス:Base
モジュール識別子:auth_basic_module
ソースファイル:mod_auth_basic.c
互換性:Apache 2.1 以降

概要

与えられたプロバイダ (訳注: 認証での照会を行う問い合わせ先) でユーザを検索し、HTTP 基本認証でアクセス制限できるようになります。 HTTP ダイジェスト認証については mod_auth_digest で提供されます。

top

AuthBasicAuthoritative ディレクティブ

説明:認証と承認を、より低いレベルのモジュールに移行させるかを 設定します。
構文:AuthBasicAuthoritative On|Off
デフォルト:AuthBasicAuthoritative On
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Base
モジュール:mod_auth_basic

AuthBasicAuthoritative ディレクティブで明示的に Offに設定すると、 与えられた認証ユーザ ID に対してユーザ ID がない またはルールがない場合に、 認証と承認の両方のプロセスが、 より低いレベルのモジュール (modules.c ファイルで定義) に移行するようにできます。 ユーザ ID がある、かつまたは、ルールが指定されている場合は、 通常のパスワードとアクセスチェックが適用されて、 認証に失敗すると "Authentication Required" 応答が返されます。

ですから、二つ以上のモジュールのデータベースで同一の ユーザ ID が現われたり、 または、正しい Require ディレクティブが二つ以上のモジュールで現われたりした場合は、 一つ目のモジュールが認定を行って、AuthAuthoritative 設定に関わらず、アクセスは移行しません。

デフォルトでは、制御は移行しません。そして、未知のユーザ ID や ルールがあっても "Authentication Required" 応答が返されます。 ですから、このディレクティブを設定しないことでシステムの安全を維持できて、また、 NCSA 準拠の挙動を強制できます。

top

AuthBasicProvider ディレクティブ

説明:この位置に対する認証プロバイダを設定します。
構文:AuthBasicProvider On|Off|provider-name [provider-name] ...
デフォルト:AuthBasicProvider On
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Base
モジュール:mod_auth_basic

AuthBasicProvider ディレクティブで、 この位置に対するユーザ認証に用いられる認証プロバイダを設定します。 On に設定するとデフォルトの認証プロバイダ (file) が使用されます。file プロバイダは mod_authn_file モジュールで実装されていますので、 このモジュールがサーバに入っていることを確認してください。

Example

<Location /secure>
AuthBasicProvider dbm
AuthDBMType SDBM
AuthDBMUserFile /www/etc/dbmpasswd
Require valid-user
</Location>

認証プロバイダについては mod_authn_dbmmod_authn_file をご覧下さい。

Off はプロバイダリストをクリアして、デフォルトの 状態に戻します。

mod/mod_auth_digest.html100644 0 0 51020 11237400230 13017 0ustar 0 0 mod_auth_digest - Apache HTTP Server
<-

Apache Module mod_auth_digest

Description:User authentication using MD5 Digest Authentication.
Status:Extension
ModuleIdentifier:auth_digest_module
SourceFile:mod_auth_digest.c

Summary

This module implements HTTP Digest Authentication (RFC2617), and provides a more secure alternative to mod_auth_basic.

top

Using Digest Authentication

Using MD5 Digest authentication is very simple. Simply set up authentication normally, using AuthType Digest and AuthDigestProvider instead of the normal AuthType Basic and AuthBasicProvider. Then add a AuthDigestDomain directive containing at least the root URI(s) for this protection space.

Appropriate user (text) files can be created using the htdigest tool.

Example:

<Location /private/>
AuthType Digest
AuthName "private area"
AuthDigestDomain /private/ http://mirror.my.dom/private2/

AuthDigestProvider file
AuthUserFile /web/auth/.digest_pw
Require valid-user
</Location>

Note

Digest authentication is more secure than Basic authentication, but only works with supporting browsers. As of September 2004, major browsers that support digest authentication include Amaya, Konqueror, MS Internet Explorer for Mac OS X and Windows (although the Windows version fails when used with a query string -- see "Working with MS Internet Explorer" below for a workaround), Mozilla, Netscape 7, Opera, and Safari. lynx does not support digest authentication. Since digest authentication is not as widely implemented as basic authentication, you should use it only in environments where all users will have supporting browsers.

top

Working with MS Internet Explorer

The Digest authentication implementation in previous Internet Explorer for Windows versions (5 and 6) had issues, namely that GET requests with a query string were not RFC compliant. There are a few ways to work around this issue.

The first way is to use POST requests instead of GET requests to pass data to your program. This method is the simplest approach if your application can work with this limitation.

Since version 2.0.51 Apache also provides a workaround in the AuthDigestEnableQueryStringHack environment variable. If AuthDigestEnableQueryStringHack is set for the request, Apache will take steps to work around the MSIE bug and remove the query string from the digest comparison. Using this method would look similar to the following.

Using Digest Authentication with MSIE:

BrowserMatch "MSIE" AuthDigestEnableQueryStringHack=On

This workaround is not necessary for MSIE 7, though enabling it does not cause any compatibility issues or significant overhead.

See the BrowserMatch directive for more details on conditionally setting environment variables.

top

AuthDigestAlgorithm Directive

Description:Selects the algorithm used to calculate the challenge and response hashes in digest authentication
Syntax:AuthDigestAlgorithm MD5|MD5-sess
Default:AuthDigestAlgorithm MD5
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_auth_digest

The AuthDigestAlgorithm directive selects the algorithm used to calculate the challenge and response hashes.

MD5-sess is not correctly implemented yet.
top

AuthDigestDomain Directive

Description:URIs that are in the same protection space for digest authentication
Syntax:AuthDigestDomain URI [URI] ...
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_auth_digest

The AuthDigestDomain directive allows you to specify one or more URIs which are in the same protection space (i.e. use the same realm and username/password info). The specified URIs are prefixes; the client will assume that all URIs "below" these are also protected by the same username/password. The URIs may be either absolute URIs (i.e. including a scheme, host, port, etc.) or relative URIs.

This directive should always be specified and contain at least the (set of) root URI(s) for this space. Omitting to do so will cause the client to send the Authorization header for every request sent to this server. Apart from increasing the size of the request, it may also have a detrimental effect on performance if AuthDigestNcCheck is on.

The URIs specified can also point to different servers, in which case clients (which understand this) will then share username/password info across multiple servers without prompting the user each time.

top

AuthDigestNcCheck Directive

Description:Enables or disables checking of the nonce-count sent by the server
Syntax:AuthDigestNcCheck On|Off
Default:AuthDigestNcCheck Off
Context:server config
Status:Extension
Module:mod_auth_digest
Not implemented yet.
top

AuthDigestNonceFormat Directive

Description:Determines how the nonce is generated
Syntax:AuthDigestNonceFormat format
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_auth_digest
Not implemented yet.
top

AuthDigestNonceLifetime Directive

Description:How long the server nonce is valid
Syntax:AuthDigestNonceLifetime seconds
Default:AuthDigestNonceLifetime 300
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_auth_digest

The AuthDigestNonceLifetime directive controls how long the server nonce is valid. When the client contacts the server using an expired nonce the server will send back a 401 with stale=true. If seconds is greater than 0 then it specifies the amount of time for which the nonce is valid; this should probably never be set to less than 10 seconds. If seconds is less than 0 then the nonce never expires.

top

AuthDigestProvider Directive

Description:Sets the authentication provider(s) for this location
Syntax:AuthDigestProvider provider-name [provider-name] ...
Default:AuthDigestProvider file
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_auth_digest

The AuthDigestProvider directive sets which provider is used to authenticate the users for this location. The default file provider is implemented by the mod_authn_file module. Make sure that the chosen provider module is present in the server.

See mod_authn_dbm, mod_authn_file, and mod_authn_dbd for providers.

top

AuthDigestQop Directive

Description:Determines the quality-of-protection to use in digest authentication
Syntax:AuthDigestQop none|auth|auth-int [auth|auth-int]
Default:AuthDigestQop auth
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_auth_digest

The AuthDigestQop directive determines the quality-of-protection to use. auth will only do authentication (username/password); auth-int is authentication plus integrity checking (an MD5 hash of the entity is also computed and checked); none will cause the module to use the old RFC-2069 digest algorithm (which does not include integrity checking). Both auth and auth-int may be specified, in which the case the browser will choose which of these to use. none should only be used if the browser for some reason does not like the challenge it receives otherwise.

auth-int is not implemented yet.
top

AuthDigestShmemSize Directive

Description:The amount of shared memory to allocate for keeping track of clients
Syntax:AuthDigestShmemSize size
Default:AuthDigestShmemSize 1000
Context:server config
Status:Extension
Module:mod_auth_digest

The AuthDigestShmemSize directive defines the amount of shared memory, that will be allocated at the server startup for keeping track of clients. Note that the shared memory segment cannot be set less than the space that is necessary for tracking at least one client. This value is dependant on your system. If you want to find out the exact value, you may simply set AuthDigestShmemSize to the value of 0 and read the error message after trying to start the server.

The size is normally expressed in Bytes, but you may let the number follow a K or an M to express your value as KBytes or MBytes. For example, the following directives are all equivalent:

AuthDigestShmemSize 1048576
AuthDigestShmemSize 1024K
AuthDigestShmemSize 1M

mod/mod_authn_alias.html100644 0 0 16671 11237400230 13024 0ustar 0 0 mod_authn_alias - Apache HTTP Server
<-

Apache Module mod_authn_alias

Description:Provides the ability to create extended authentication providers based on actual providers
Status:Extension
ModuleIdentifier:authn_alias_module
SourceFile:mod_authn_alias.c
Compatibility:Available in Apache 2.1 and later

Summary

This module allows extended authentication providers to be created within the configuration file and assigned an alias name. The alias providers can then be referenced through the directives AuthBasicProvider or AuthDigestProvider in the same way as a base authentication provider. Besides the ability to create and alias an extended provider, it also allows the same extended authentication provider to be reference by multiple locations.

Directives

Topics

top

Examples

This example checks for passwords in two different text files.

Checking multiple text password files

# Check here first
<AuthnProviderAlias file file1>
AuthUserFile /www/conf/passwords1
</AuthnProviderAlias>

# Then check here
<AuthnProviderAlias file file2>
AuthUserFile /www/conf/passwords2
</AuthnProviderAlias>

<Directory /var/web/pages/secure>
AuthBasicProvider file1 file2

AuthType Basic
AuthName "Protected Area"
Require valid-user
</Directory>

The example below creates two different ldap authentication provider aliases based on the ldap provider. This allows a single authenticated location to be serviced by multiple ldap hosts:

Checking multiple LDAP servers

LoadModule authn_alias_module modules/mod_authn_alias.so

<AuthnProviderAlias ldap ldap-alias1>
AuthLDAPBindDN cn=youruser,o=ctx
AuthLDAPBindPassword yourpassword
AuthLDAPURL ldap://ldap.host/o=ctx
</AuthnProviderAlias>

<AuthnProviderAlias ldap ldap-other-alias>
AuthLDAPBindDN cn=yourotheruser,o=dev
AuthLDAPBindPassword yourotherpassword
AuthLDAPURL ldap://other.ldap.host/o=dev?cn
</AuthnProviderAlias>

Alias /secure /webpages/secure
<Directory /webpages/secure>
Order deny,allow
Allow from all

AuthBasicProvider ldap-other-alias ldap-alias1

AuthType Basic
AuthName LDAP_Protected_Place
AuthzLDAPAuthoritative off
Require valid-user
</Directory>

top

<AuthnProviderAlias> Directive

Description:Enclose a group of directives that represent an extension of a base authentication provider and referenced by the specified alias
Syntax:<AuthnProviderAlias baseProvider Alias> ... </AuthnProviderAlias>
Context:server config
Status:Extension
Module:mod_authn_alias

<AuthnProviderAlias> and </AuthnProviderAlias> are used to enclose a group of authentication directives that can be referenced by the alias name using one of the directives AuthBasicProvider or AuthDigestProvider.

mod/mod_authn_anon.html100644 0 0 35100 11237400230 12652 0ustar 0 0 mod_authn_anon - Apache HTTP サーバ
<-

Apache モジュール mod_authn_anon

説明:認証が必要な領域への "anonymous" ユーザのアクセスを許可する
ステータス:Extension
モジュール識別子:authn_anon_module
ソースファイル:mod_authn_anon.c
互換性:Apache 2.1 以降

概要

このモジュールは mod_auth_basic のような 認証フロントエンドとして、anonymous-ftp サイトのような、「魔法の」ユーザ ID 'anonymous' と電子メールアドレスをパスワードにしたユーザ認証を 行なう機能を提供します。この電子メールアドレスはログ収集することが できます。

他の (データベースによる) アクセス制御方法と組み合わせることで、 「未登録」ユーザに対してサイトを公開しつつ、効率よくユーザ追跡したり、 ユーザのプロファイルに応じたカスタマイズをしたりできます。 このような認証に基づいたユーザ追跡の利点の一つは、 マジッククッキーに基づくユーザ追跡方法や、 珍妙な URL の接頭辞や接尾辞を利用したユーザ追跡方法とは異なり、 完全にブラウザ非依存であり、ユーザ間で URL を共有することができるという 点です。

mod_auth_basic を使用している場合は、このモジュールは AuthBasicProvideranon という値を設定することで起動されます。

top

以下の例は「普通」の htpasswd ファイルに基づいた認証と組み合わされて おり、以下の要件を見たすユーザを「ゲスト」として許可します:

  • ユーザは userID を入力しなければなりません。 (Anonymous_NoUserID)
  • ユーザはパスワードを入力しなければなりません。 (Anonymous_MustGiveEmail)
  • 入力されたパスワードは有効な電子メールアドレスでなければ なりません。すなわち、少くとも一つの '@' と '.' が 含まれている必要があります。 (Anonymous_VerifyEmail)
  • userID は anonymous guest www test welcome のどれかでなければなりません。 ユーザ名の比較は大文字小文字を区別しません。
  • パスワード欄に入力された電子メールアドレスはエラーログファイルに ロギングされます。 (Anonymous_LogEmail)

<Directory /foo> AuthName "Use 'anonymous' & Email address for guest entry"
AuthType Basic
AuthBasicProvider file anon
AuthUserFile /path/to/your/.htpasswd

Anonymous_NoUserID off
Anonymous_MustGiveEmail on
Anonymous_VerifyEmail on
Anonymous_LogEmail on
Anonymous anonymous guest www test welcome

Order Deny,Allow
Allow from all

Require valid-user
</Directory>

top

Anonymous ディレクティブ

説明:パスワードの検査無しでアクセスを許可する userID を指定する
構文:Anonymous user [user] ...
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Extension
モジュール:mod_authn_anon

パスワードの検査をしないでアクセスを許可する「魔法の」 userID を 設定します。userID 中に空白を使えるようにするため、 エスケープ文字 \ による方法と、引用符 ' と " によるクオーティング を使うことができます。

ユーザ名の比較は大文字小文字を区別しないことに 注意してください。
魔法のユーザ名 'anonymous' が許可されている userID に 含むようにすることは強く推奨されています。

例:

Anonymous anonymous "Not Registered" "I don't know"

これは、userID "anonymous", "AnonyMous", "Not Registered", "I Don't Know" のどれかを使っても パスワード無しでユーザがサイトに入れるようにします。

Apache 2.1 では userID に "*" を指定することができます。 この場合、すべてのuserID を許可します。

top

Anonymous_LogEmail ディレクティブ

説明:入力されたパスワードがエラーログにロギングされるかどうかを 設定する
構文:Anonymous_LogEmail On|Off
デフォルト:Anonymous_LogEmail On
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Extension
モジュール:mod_authn_anon

デフォルトの On に設定された場合は、 入力された (まっとうな電子メールアドレスであることが 期待される) 「パスワード」がエラーログにロギングされます。

top

Anonymous_MustGiveEmail ディレクティブ

説明:空パスワードを許可するかどうかを指定する
構文:Anonymous_MustGiveEmail On|Off
デフォルト:Anonymous_MustGiveEmail On
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Extension
モジュール:mod_authn_anon

ユーザがパスワードとして電子メールアドレスを指定する必要があるかどうかを 設定します。これは空パスワードを禁止します。

top

Anonymous_NoUserID ディレクティブ

説明:空 userID を許可するかを指定する
構文:Anonymous_NoUserID On|Off
デフォルト:Anonymous_NoUserID Off
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Extension
モジュール:mod_authn_anon

On に設定すると、ユーザは userID (とおそらくは パスワード欄も) 空にすることができます。これは単にリターンキーを 叩いたり OK ボタンを直接クリックしたりする MS-Explorer ユーザには 非常に便利です。そのような操作はごくごく自然なものでしょう。

top

Anonymous_VerifyEmail ディレクティブ

説明:パスワード欄が正しい形式の電子メールアドレスであることを 調べるかどうかを設定する
構文:Anonymous_VerifyEmail On|Off
デフォルト:Anonymous_VerifyEmail Off
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Extension
モジュール:mod_authn_anon

On に設定されている場合、ユーザが有効な電子メール アドレスを入力することを推奨するため、入力された「パスワード」は 少なくとも一つの '@' と '.' を含んでいるかどうかを調べます (上の Anonymous_LogEmail 参照)。

mod/mod_authn_dbd.html100644 0 0 24761 11237400230 12463 0ustar 0 0 mod_authn_dbd - Apache HTTP Server
<-

Apache Module mod_authn_dbd

Description:User authentication using an SQL database
Status:Extension
ModuleIdentifier:authn_dbd_module
SourceFile:mod_authn_dbd.c
Compatibility:Available in Apache 2.1 and later

Summary

This module provides authentication front-ends such as mod_auth_digest and mod_auth_basic to authenticate users by looking up users in SQL tables. Similar functionality is provided by, for example, mod_authn_file.

This module relies on mod_dbd to specify the backend database driver and connection parameters, and manage the database connections.

When using mod_auth_basic or mod_auth_digest, this module is invoked via the AuthBasicProvider or AuthDigestProvider with the dbd value.

top

Configuration Example

This simple example shows use of this module in the context of the Authentication and DBD frameworks. Please note that you need to load an authorization module, such as mod_authz_user, to get it working.

# mod_dbd configuration
DBDriver pgsql
DBDParams "dbname=apacheauth user=apache password=xxxxxx"

DBDMin  4
DBDKeep 8
DBDMax  20
DBDExptime 300

<Directory /usr/www/myhost/private>
  # core authentication and mod_auth_basic configuration
  # for mod_authn_dbd
  AuthType Basic
  AuthName "My Server"
  AuthBasicProvider dbd

  # core authorization configuration
  Require valid-user

  # mod_authn_dbd SQL query to authenticate a user
  AuthDBDUserPWQuery \
    "SELECT password FROM authn WHERE user = %s"
</Directory>
top

Exposing Login Information

If httpd was built against APR version 1.3.0 or higher, then whenever a query is made to the database server, all column values in the first row returned by the query are placed in the environment, using environment variables with the prefix "AUTHENTICATE_".

If a database query for example returned the username, full name and telephone number of a user, a CGI program will have access to this information without the need to make a second independent database query to gather this additional information.

This has the potential to dramatically simplify the coding and configuration required in some web applications.

top

AuthDBDUserPWQuery Directive

Description:SQL query to look up a password for a user
Syntax:AuthDBDUserPWQuery query
Context:directory
Status:Extension
Module:mod_authn_dbd

The AuthDBDUserPWQuery specifies an SQL query to look up a password for a specified user. The user's ID will be passed as a single string parameter when the SQL query is executed. It may be referenced within the query statement using a %s format specifier.

Example

AuthDBDUserPWQuery \
  "SELECT password FROM authn WHERE user = %s"

The first column value of the first row returned by the query statement should be a string containing the encrypted password. Subsequent rows will be ignored. If no rows are returned, the user will not be authenticated through mod_authn_dbd.

If httpd was built against APR version 1.3.0 or higher, any additional column values in the first row returned by the query statement will be stored as environment variables with names of the form AUTHENTICATE_COLUMN.

top

AuthDBDUserRealmQuery Directive

Description:SQL query to look up a password hash for a user and realm.
Syntax:AuthDBDUserRealmQuery query
Context:directory
Status:Extension
Module:mod_authn_dbd

The AuthDBDUserRealmQuery specifies an SQL query to look up a password for a specified user and realm. The user's ID and the realm, in that order, will be passed as string parameters when the SQL query is executed. They may be referenced within the query statement using %s format specifiers.

Example

AuthDBDUserRealmQuery \
  "SELECT password FROM authn WHERE user = %s AND realm = %s"

The first column value of the first row returned by the query statement should be a string containing the encrypted password. Subsequent rows will be ignored. If no rows are returned, the user will not be authenticated through mod_authn_dbd.

If httpd was built against APR version 1.3.0 or higher, any additional column values in the first row returned by the query statement will be stored as environment variables with names of the form AUTHENTICATE_COLUMN.

mod/mod_authn_dbm.html100644 0 0 21767 11237400230 12477 0ustar 0 0 mod_authn_dbm - Apache HTTP サーバ
<-

Apache モジュール mod_authn_dbm

説明:DBM ファイルを用いたユーザ認証
ステータス:Extension
モジュール識別子:authn_dbm_module
ソースファイル:mod_authn_dbm.c
互換性:Apache 2.1 以降

概要

本モジュールは mod_auth_digestmod_auth_basic といった認証フロントエンドに対して、 dbm パスワードファイル内からのユーザ検索による ユーザ認証機能を提供します。似たような機能は mod_authn_file でも提供されています。

mod_auth_basicmod_auth_digest を使用する際には、このモジュールは AuthBasicProviderAuthDigestPrividerdbm と指定することで起動されます。

top

AuthDBMType ディレクティブ

説明:パスワードを保存するために必要なデータベースファイルの種類を 設定する
構文:AuthDBMType default|SDBM|GDBM|NDBM|DB
デフォルト:AuthDBMType default
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Extension
モジュール:mod_authn_dbm

パスワードを保存するために使用するデータベースファイルの種類を 設定します。デフォルトのデータベースの種類はコンパイル時に決まります。 他の種類のデータベースが使用可能かどうかも コンパイル時の設定に依存します。

パスワードファイルを作成するのに使用するプログラムが同じ種類のデータベースを 使用するように設定することは非常に重要です。

top

AuthDBMUserFile ディレクティブ

説明:認証用のユーザとパスワードのリストを保持している データベースファイル名を設定する
構文:AuthDBMUserFile file-path
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Extension
モジュール:mod_authn_dbm

AuthDBMUserFile ディレクティブは 認証用のユーザとパスワードのリストを保持している DBM ファイルの 名前を設定します。File-path はユーザファイルへの 絶対パスです。

ユーザファイルのキーはユーザ名です。ユーザに対して返される値は 暗号化されたパスワードで、その後に、コロンに続いて任意のデータが 続いていることもあります。コロンとその後のデータはサーバは 無視します。

セキュリティ

AuthDBMUserFile は、 ウェブサーバのドキュメントツリーの外側に保管するようにしてください。 保護しようとしているディレクトリ以下には 置かないで下さい。 そうしないとクライアントが AuthUserFile を ダウンロードできてしまいます。

重要な互換性に関する注意: apache module の dbmopen の実装は 文字列が NULL で終わっていることに依存するのではなく、DBM データストラクチャ のハッシュ値の文字列の長さを読み取ります。Netscape ウェブサーバなど、 アプリケーションの中には文字列が NULL で終わっていることに依存している ものがあります。ですから、異なるアプリケーション間での DBM ファイルの 使用に問題がある場合は、これが原因になっている可能性があります。

Apache には dbmmanage という perl スクリプトが含まれています。このプログラムを使ってこの モジュールが使用する DBM フォーマットのパスワードファイルを作成したり 更新したりすることができます。

mod/mod_authn_default.html100644 0 0 11635 11237400230 13352 0ustar 0 0 mod_authn_default - Apache HTTP サーバ
<-

Apache モジュール mod_authn_default

説明:認証フォールバックモジュール
ステータス:Base
モジュール識別子:authn_default_module
ソースファイル:mod_authn_default.c
互換性:Apache 2.1 以降

概要

mod_auth_basic のような認証モジュールを 設定しなかった場合は、本モジュールがフォールバックとなります。 ユーザから提示されたどんな証書も単に拒否します。

ディレクティブ

top

AuthDefaultAuthoritative ディレクティブ

説明:次の低次レベルの認証モジュールに制御を渡すかどうかを 設定します
構文:AuthDefaultAuthoritative On|Off
デフォルト:AuthDefaultAuthoritative On
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Base
モジュール:mod_authn_default

AuthDefaultAuthoritative ディレクティブを 明示的に Off に設定すると、 認証を次の (modules.c ファイルで定義されている) 低次レベルのモジュールに渡します。

注意

mod_authn_default 自体がとても低い レベルとして定義されていますので、通常はこれよりも低次の モジュールは存在しません。ですから AuthDefaultAuthoritative はデフォルト (On) のままにしたほうが良いでしょう。

mod/mod_authn_file.html100644 0 0 20600 11237400230 12635 0ustar 0 0 mod_authn_file - Apache HTTP サーバ
<-

Apache モジュール mod_authn_file

説明:テキストファイルを用いたユーザ認証
ステータス:Base
モジュール識別子:authn_file_module
ソースファイル:mod_authn_file.c
互換性:Apache 2.1 以降

概要

本モジュールは mod_auth_digestmod_auth_basic といった認証フロントエンドに対して、 プレインテキストのパスワードファイル内からユーザを検索することで、 ユーザ認証機能を提供します。似たような機能は mod_authn_dbm でも提供されています。

mod_auth_basicmod_auth_digest を使用する際には、 AuthBasicProviderAuthDigestPrividerfile と指定することでこのモジュールは起動されます。

top

AuthUserFile ディレクティブ

説明:認証に使用するユーザとパスワードの一覧が格納されている、 テキストファイルの名前を設定する
構文:AuthUserFile file-path
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Base
モジュール:mod_authn_file

AuthUserFile ディレクティブは、 ユーザ認証のためのユーザとパスワードの一覧を格納した テキストファイルの名前を設定します。file-path はユーザファイルへのパスです。 もし絶対パスでなければ、 ServerRoot からの相対パスとして扱われます。

ユーザファイルの各行には、ユーザ名、コロン、 暗号化したパスワードを記述します。 同一ユーザ ID が複数回登録された時は、 mod_authn_file は最初に見つかったパスワードを使用して認証します。

バイナリ配布の一部としてインストールされるか、 あるいは src/support にある htpasswd ユーティリティで、この HTTP 基本認証 用パスワードファイルをメインテナンスします。 詳細は man ページをご覧頂くとして、簡単には:

初期 ID username で、Filename というパスワードファイルを生成します。 次のコマンドを発行するとパスワードが要求されます:

htpasswd -c Filename username

パスワードファイル Filename に、username2 を追加したり修正したりします:

htpasswd Filename username2

(訳注: 非常に多くのユーザを登録すると大きなファイルになりますが) 大きなテキストファイルを検索するのは非常に効率が悪い ということに注意してください。そのような必要のある時は、 AuthDBMUserFile を代わりに使ってください。

HTTP ダイジェスト認証を使用する場合は、 htpasswd プログラムでは不十分です。その代わりに htdigest を使用してください。ダイジェスト認証用のデータと 基本認証用のデータを同一ファイルに混ぜて保存できない、 ということに注意してください。

セキュリティ

AuthUserFile は、ウェブサーバのドキュメントツリーの外側に保管するようにしてください。 保護しようとしているディレクトリ以下には、置かないで下さい。 そうしないと AuthUserFile は ダウンロードできてしまいます。

mod/mod_authnz_ldap.html100644 0 0 155255 11237400230 13067 0ustar 0 0 mod_authnz_ldap - Apache HTTP Server
<-

Apache Module mod_authnz_ldap

Description:Allows an LDAP directory to be used to store the database for HTTP Basic authentication.
Status:Extension
ModuleIdentifier:authnz_ldap_module
SourceFile:mod_authnz_ldap.c
Compatibility:Available in version 2.1 and later

Summary

This module provides authentication front-ends such as mod_auth_basic to authenticate users through an ldap directory.

mod_authnz_ldap supports the following features:

  • Known to support the OpenLDAP SDK (both 1.x and 2.x), Novell LDAP SDK and the iPlanet (Netscape) SDK.
  • Complex authorization policies can be implemented by representing the policy with LDAP filters.
  • Uses extensive caching of LDAP operations via mod_ldap.
  • Support for LDAP over SSL (requires the Netscape SDK) or TLS (requires the OpenLDAP 2.x SDK or Novell LDAP SDK).

When using mod_auth_basic, this module is invoked via the AuthBasicProvider directive with the ldap value.

top
top

Operation

There are two phases in granting access to a user. The first phase is authentication, in which the mod_authnz_ldap authentication provider verifies that the user's credentials are valid. This is also called the search/bind phase. The second phase is authorization, in which mod_authnz_ldap determines if the authenticated user is allowed access to the resource in question. This is also known as the compare phase.

mod_authnz_ldap registers both an authn_ldap authentication provider and an authz_ldap authorization handler. The authn_ldap authentication provider can be enabled through the AuthBasicProvider directive using the ldap value. The authz_ldap handler extends the Require directive's authorization types by adding ldap-user, ldap-dn and ldap-group values.

The Authentication Phase

During the authentication phase, mod_authnz_ldap searches for an entry in the directory that matches the username that the HTTP client passes. If a single unique match is found, then mod_authnz_ldap attempts to bind to the directory server using the DN of the entry plus the password provided by the HTTP client. Because it does a search, then a bind, it is often referred to as the search/bind phase. Here are the steps taken during the search/bind phase.

  1. Generate a search filter by combining the attribute and filter provided in the AuthLDAPURL directive with the username passed by the HTTP client.
  2. Search the directory using the generated filter. If the search does not return exactly one entry, deny or decline access.
  3. Fetch the distinguished name of the entry retrieved from the search and attempt to bind to the LDAP server using the DN and the password passed by the HTTP client. If the bind is unsuccessful, deny or decline access.

The following directives are used during the search/bind phase

AuthLDAPURL Specifies the LDAP server, the base DN, the attribute to use in the search, as well as the extra search filter to use.
AuthLDAPBindDN An optional DN to bind with during the search phase.
AuthLDAPBindPassword An optional password to bind with during the search phase.

The Authorization Phase

During the authorization phase, mod_authnz_ldap attempts to determine if the user is authorized to access the resource. Many of these checks require mod_authnz_ldap to do a compare operation on the LDAP server. This is why this phase is often referred to as the compare phase. mod_authnz_ldap accepts the following Require directives to determine if the credentials are acceptable:

  • Grant access if there is a Require ldap-user directive, and the username in the directive matches the username passed by the client.
  • Grant access if there is a Require ldap-dn directive, and the DN in the directive matches the DN fetched from the LDAP directory.
  • Grant access if there is a Require ldap-group directive, and the DN fetched from the LDAP directory (or the username passed by the client) occurs in the LDAP group.
  • Grant access if there is a Require ldap-attribute directive, and the attribute fetched from the LDAP directory matches the given value.
  • Grant access if there is a Require ldap-filter directive, and the search filter successfully finds a single user object that matches the dn of the authenticated user.
  • otherwise, deny or decline access

Other Require values may also be used which may require loading additional authorization modules. Note that if you use a Require value from another authorization module, you will need to ensure that AuthzLDAPAuthoritative is set to off to allow the authorization phase to fall back to the module providing the alternate Require value. When no LDAP-specific Require directives are used, authorization is allowed to fall back to other modules as if AuthzLDAPAuthoritative was set to off.

mod_authnz_ldap uses the following directives during the compare phase:

AuthLDAPURL The attribute specified in the URL is used in compare operations for the Require ldap-user operation.
AuthLDAPCompareDNOnServer Determines the behavior of the Require ldap-dn directive.
AuthLDAPGroupAttribute Determines the attribute to use for comparisons in the Require ldap-group directive.
AuthLDAPGroupAttributeIsDN Specifies whether to use the user DN or the username when doing comparisons for the Require ldap-group directive.
top

The Require Directives

Apache's Require directives are used during the authorization phase to ensure that a user is allowed to access a resource. mod_authnz_ldap extends the authorization types with ldap-user, ldap-dn, ldap-group, ldap-attribute and ldap-filter. Other authorization types may also be used but may require that additional authorization modules be loaded.

Require valid-user

If this directive exists, mod_authnz_ldap grants access to any user that has successfully authenticated during the search/bind phase. Requires that mod_authz_user be loaded.

Require ldap-user

The Require ldap-user directive specifies what usernames can access the resource. Once mod_authnz_ldap has retrieved a unique DN from the directory, it does an LDAP compare operation using the username specified in the Require ldap-user to see if that username is part of the just-fetched LDAP entry. Multiple users can be granted access by putting multiple usernames on the line, separated with spaces. If a username has a space in it, then it must be surrounded with double quotes. Multiple users can also be granted access by using multiple Require ldap-user directives, with one user per line. For example, with a AuthLDAPURL of ldap://ldap/o=Airius?cn (i.e., cn is used for searches), the following Require directives could be used to restrict access:

Require ldap-user "Barbara Jenson"
Require ldap-user "Fred User"
Require ldap-user "Joe Manager"

Because of the way that mod_authnz_ldap handles this directive, Barbara Jenson could sign on as Barbara Jenson, Babs Jenson or any other cn that she has in her LDAP entry. Only the single Require ldap-user line is needed to support all values of the attribute in the user's entry.

If the uid attribute was used instead of the cn attribute in the URL above, the above three lines could be condensed to

Require ldap-user bjenson fuser jmanager

Require ldap-group

This directive specifies an LDAP group whose members are allowed access. It takes the distinguished name of the LDAP group. Note: Do not surround the group name with quotes. For example, assume that the following entry existed in the LDAP directory:

dn: cn=Administrators, o=Airius
objectClass: groupOfUniqueNames
uniqueMember: cn=Barbara Jenson, o=Airius
uniqueMember: cn=Fred User, o=Airius

The following directive would grant access to both Fred and Barbara:

Require ldap-group cn=Administrators, o=Airius

Behavior of this directive is modified by the AuthLDAPGroupAttribute and AuthLDAPGroupAttributeIsDN directives.

Require ldap-dn

The Require ldap-dn directive allows the administrator to grant access based on distinguished names. It specifies a DN that must match for access to be granted. If the distinguished name that was retrieved from the directory server matches the distinguished name in the Require ldap-dn, then authorization is granted. Note: do not surround the distinguished name with quotes.

The following directive would grant access to a specific DN:

Require ldap-dn cn=Barbara Jenson, o=Airius

Behavior of this directive is modified by the AuthLDAPCompareDNOnServer directive.

Require ldap-attribute

The Require ldap-attribute directive allows the administrator to grant access based on attributes of the authenticated user in the LDAP directory. If the attribute in the directory matches the value given in the configuration, access is granted.

The following directive would grant access to anyone with the attribute employeeType = active

Require ldap-attribute employeeType=active

Multiple attribute/value pairs can be specified on the same line separated by spaces or they can be specified in multiple Require ldap-attribute directives. The effect of listing multiple attribute/values pairs is an OR operation. Access will be granted if any of the listed attribute values match the value of the corresponding attribute in the user object. If the value of the attribute contains a space, only the value must be within double quotes.

The following directive would grant access to anyone with the city attribute equal to "San Jose" or status equal to "Active"

Require ldap-attribute city="San Jose" status=active

Require ldap-filter

The Require ldap-filter directive allows the administrator to grant access based on a complex LDAP search filter. If the dn returned by the filter search matches the authenticated user dn, access is granted.

The following directive would grant access to anyone having a cell phone and is in the marketing department

Require ldap-filter &(cell=*)(department=marketing)

The difference between the Require ldap-filter directive and the Require ldap-attribute directive is that ldap-filter performs a search operation on the LDAP directory using the specified search filter rather than a simple attribute comparison. If a simple attribute comparison is all that is required, the comparison operation performed by ldap-attribute will be faster than the search operation used by ldap-filter especially within a large directory.

top

Examples

  • Grant access to anyone who exists in the LDAP directory, using their UID for searches.

    AuthLDAPURL "ldap://ldap1.airius.com:389/ou=People, o=Airius?uid?sub?(objectClass=*)"
    Require valid-user

  • The next example is the same as above; but with the fields that have useful defaults omitted. Also, note the use of a redundant LDAP server.

    AuthLDAPURL "ldap://ldap1.airius.com ldap2.airius.com/ou=People, o=Airius"
    Require valid-user

  • The next example is similar to the previous one, but it uses the common name instead of the UID. Note that this could be problematical if multiple people in the directory share the same cn, because a search on cn must return exactly one entry. That's why this approach is not recommended: it's a better idea to choose an attribute that is guaranteed unique in your directory, such as uid.

    AuthLDAPURL "ldap://ldap.airius.com/ou=People, o=Airius?cn"
    Require valid-user

  • Grant access to anybody in the Administrators group. The users must authenticate using their UID.

    AuthLDAPURL ldap://ldap.airius.com/o=Airius?uid
    Require ldap-group cn=Administrators, o=Airius

  • The next example assumes that everyone at Airius who carries an alphanumeric pager will have an LDAP attribute of qpagePagerID. The example will grant access only to people (authenticated via their UID) who have alphanumeric pagers:

    AuthLDAPURL ldap://ldap.airius.com/o=Airius?uid??(qpagePagerID=*)
    Require valid-user

  • The next example demonstrates the power of using filters to accomplish complicated administrative requirements. Without filters, it would have been necessary to create a new LDAP group and ensure that the group's members remain synchronized with the pager users. This becomes trivial with filters. The goal is to grant access to anyone who has a pager, plus grant access to Joe Manager, who doesn't have a pager, but does need to access the same resource:

    AuthLDAPURL ldap://ldap.airius.com/o=Airius?uid??(|(qpagePagerID=*)(uid=jmanager))
    Require valid-user

    This last may look confusing at first, so it helps to evaluate what the search filter will look like based on who connects, as shown below. If Fred User connects as fuser, the filter would look like

    (&(|(qpagePagerID=*)(uid=jmanager))(uid=fuser))

    The above search will only succeed if fuser has a pager. When Joe Manager connects as jmanager, the filter looks like

    (&(|(qpagePagerID=*)(uid=jmanager))(uid=jmanager))

    The above search will succeed whether jmanager has a pager or not.

top

Using TLS

To use TLS, see the mod_ldap directives LDAPTrustedClientCert, LDAPTrustedGlobalCert and LDAPTrustedMode.

An optional second parameter can be added to the AuthLDAPURL to override the default connection type set by LDAPTrustedMode. This will allow the connection established by an ldap:// Url to be upgraded to a secure connection on the same port.

top

Using SSL

To use SSL, see the mod_ldap directives LDAPTrustedClientCert, LDAPTrustedGlobalCert and LDAPTrustedMode.

To specify a secure LDAP server, use ldaps:// in the AuthLDAPURL directive, instead of ldap://.

top

Exposing Login Information

When this module performs authentication, LDAP attributes specified in the AuthLDAPUrl directive are placed in environment variables with the prefix "AUTHENTICATE_".

If the attribute field contains the username, common name and telephone number of a user, a CGI program will have access to this information without the need to make a second independent LDAP query to gather this additional information.

This has the potential to dramatically simplify the coding and configuration required in some web applications.

top

Using Microsoft FrontPage with mod_authnz_ldap

Normally, FrontPage uses FrontPage-web-specific user/group files (i.e., the mod_authn_file and mod_authz_groupfile modules) to handle all authentication. Unfortunately, it is not possible to just change to LDAP authentication by adding the proper directives, because it will break the Permissions forms in the FrontPage client, which attempt to modify the standard text-based authorization files.

Once a FrontPage web has been created, adding LDAP authentication to it is a matter of adding the following directives to every .htaccess file that gets created in the web

AuthLDAPURL            "the url"
AuthGroupFile mygroupfile
Require group mygroupfile

How It Works

FrontPage restricts access to a web by adding the Require valid-user directive to the .htaccess files. The Require valid-user directive will succeed for any user who is valid as far as LDAP is concerned. This means that anybody who has an entry in the LDAP directory is considered a valid user, whereas FrontPage considers only those people in the local user file to be valid. By substituting the ldap-group with group file authorization, Apache is allowed to consult the local user file (which is managed by FrontPage) - instead of LDAP - when handling authorizing the user.

Once directives have been added as specified above, FrontPage users will be able to perform all management operations from the FrontPage client.

Caveats

  • When choosing the LDAP URL, the attribute to use for authentication should be something that will also be valid for putting into a mod_authn_file user file. The user ID is ideal for this.
  • When adding users via FrontPage, FrontPage administrators should choose usernames that already exist in the LDAP directory (for obvious reasons). Also, the password that the administrator enters into the form is ignored, since Apache will actually be authenticating against the password in the LDAP database, and not against the password in the local user file. This could cause confusion for web administrators.
  • Apache must be compiled with mod_auth_basic, mod_authn_file and mod_authz_groupfile in order to use FrontPage support. This is because Apache will still use the mod_authz_groupfile group file for determine the extent of a user's access to the FrontPage web.
  • The directives must be put in the .htaccess files. Attempting to put them inside <Location> or <Directory> directives won't work. This is because mod_authnz_ldap has to be able to grab the AuthGroupFile directive that is found in FrontPage .htaccess files so that it knows where to look for the valid user list. If the mod_authnz_ldap directives aren't in the same .htaccess file as the FrontPage directives, then the hack won't work, because mod_authnz_ldap will never get a chance to process the .htaccess file, and won't be able to find the FrontPage-managed user file.
top

AuthLDAPBindDN Directive

Description:Optional DN to use in binding to the LDAP server
Syntax:AuthLDAPBindDN distinguished-name
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_authnz_ldap

An optional DN used to bind to the server when searching for entries. If not provided, mod_authnz_ldap will use an anonymous bind.

top

AuthLDAPBindPassword Directive

Description:Password used in conjuction with the bind DN
Syntax:AuthLDAPBindPassword password
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_authnz_ldap

A bind password to use in conjunction with the bind DN. Note that the bind password is probably sensitive data, and should be properly protected. You should only use the AuthLDAPBindDN and AuthLDAPBindPassword if you absolutely need them to search the directory.

top

AuthLDAPCharsetConfig Directive

Description:Language to charset conversion configuration file
Syntax:AuthLDAPCharsetConfig file-path
Context:server config
Status:Extension
Module:mod_authnz_ldap

The AuthLDAPCharsetConfig directive sets the location of the language to charset conversion configuration file. File-path is relative to the ServerRoot. This file specifies the list of language extensions to character sets. Most administrators use the provided charset.conv file, which associates common language extensions to character sets.

The file contains lines in the following format:

Language-Extension charset [Language-String] ...

The case of the extension does not matter. Blank lines, and lines beginning with a hash character (#) are ignored.

top

AuthLDAPCompareDNOnServer Directive

Description:Use the LDAP server to compare the DNs
Syntax:AuthLDAPCompareDNOnServer on|off
Default:AuthLDAPCompareDNOnServer on
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_authnz_ldap

When set, mod_authnz_ldap will use the LDAP server to compare the DNs. This is the only foolproof way to compare DNs. mod_authnz_ldap will search the directory for the DN specified with the Require dn directive, then, retrieve the DN and compare it with the DN retrieved from the user entry. If this directive is not set, mod_authnz_ldap simply does a string comparison. It is possible to get false negatives with this approach, but it is much faster. Note the mod_ldap cache can speed up DN comparison in most situations.

top

AuthLDAPDereferenceAliases Directive

Description:When will the module de-reference aliases
Syntax:AuthLDAPDereferenceAliases never|searching|finding|always
Default:AuthLDAPDereferenceAliases Always
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_authnz_ldap

This directive specifies when mod_authnz_ldap will de-reference aliases during LDAP operations. The default is always.

top

AuthLDAPGroupAttribute Directive

Description:LDAP attributes used to check for group membership
Syntax:AuthLDAPGroupAttribute attribute
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_authnz_ldap

This directive specifies which LDAP attributes are used to check for group membership. Multiple attributes can be used by specifying this directive multiple times. If not specified, then mod_authnz_ldap uses the member and uniquemember attributes.

top

AuthLDAPGroupAttributeIsDN Directive

Description:Use the DN of the client username when checking for group membership
Syntax:AuthLDAPGroupAttributeIsDN on|off
Default:AuthLDAPGroupAttributeIsDN on
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_authnz_ldap

When set on, this directive says to use the distinguished name of the client username when checking for group membership. Otherwise, the username will be used. For example, assume that the client sent the username bjenson, which corresponds to the LDAP DN cn=Babs Jenson, o=Airius. If this directive is set, mod_authnz_ldap will check if the group has cn=Babs Jenson, o=Airius as a member. If this directive is not set, then mod_authnz_ldap will check if the group has bjenson as a member.

top

AuthLDAPRemoteUserAttribute Directive

Description:Use the value of the attribute returned during the user query to set the REMOTE_USER environment variable
Syntax:AuthLDAPRemoteUserAttribute uid
Default:none
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_authnz_ldap

If this directive is set, the value of the REMOTE_USER environment variable will be set to the value of the attribute specified. Make sure that this attribute is included in the list of attributes in the AuthLDAPUrl definition, otherwise this directive will have no effect. This directive, if present, takes precedence over AuthLDAPRemoteUserIsDN. This directive is useful should you want people to log into a website using an email address, but a backend application expects the username as a userid.

top

AuthLDAPRemoteUserIsDN Directive

Description:Use the DN of the client username to set the REMOTE_USER environment variable
Syntax:AuthLDAPRemoteUserIsDN on|off
Default:AuthLDAPRemoteUserIsDN off
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_authnz_ldap

If this directive is set to on, the value of the REMOTE_USER environment variable will be set to the full distinguished name of the authenticated user, rather than just the username that was passed by the client. It is turned off by default.

top

AuthLDAPUrl Directive

Description:URL specifying the LDAP search parameters
Syntax:AuthLDAPUrl url [NONE|SSL|TLS|STARTTLS]
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_authnz_ldap

An RFC 2255 URL which specifies the LDAP search parameters to use. The syntax of the URL is

ldap://host:port/basedn?attribute?scope?filter

ldap
For regular ldap, use the string ldap. For secure LDAP, use ldaps instead. Secure LDAP is only available if Apache was linked to an LDAP library with SSL support.
host:port

The name/port of the ldap server (defaults to localhost:389 for ldap, and localhost:636 for ldaps). To specify multiple, redundant LDAP servers, just list all servers, separated by spaces. mod_authnz_ldap will try connecting to each server in turn, until it makes a successful connection.

Once a connection has been made to a server, that connection remains active for the life of the httpd process, or until the LDAP server goes down.

If the LDAP server goes down and breaks an existing connection, mod_authnz_ldap will attempt to re-connect, starting with the primary server, and trying each redundant server in turn. Note that this is different than a true round-robin search.

basedn
The DN of the branch of the directory where all searches should start from. At the very least, this must be the top of your directory tree, but could also specify a subtree in the directory.
attribute
The attribute to search for. Although RFC 2255 allows a comma-separated list of attributes, only the first attribute will be used, no matter how many are provided. If no attributes are provided, the default is to use uid. It's a good idea to choose an attribute that will be unique across all entries in the subtree you will be using.
scope
The scope of the search. Can be either one or sub. Note that a scope of base is also supported by RFC 2255, but is not supported by this module. If the scope is not provided, or if base scope is specified, the default is to use a scope of sub.
filter
A valid LDAP search filter. If not provided, defaults to (objectClass=*), which will search for all objects in the tree. Filters are limited to approximately 8000 characters (the definition of MAX_STRING_LEN in the Apache source code). This should be more than sufficient for any application.

When doing searches, the attribute, filter and username passed by the HTTP client are combined to create a search filter that looks like (&(filter)(attribute=username)).

For example, consider an URL of ldap://ldap.airius.com/o=Airius?cn?sub?(posixid=*). When a client attempts to connect using a username of Babs Jenson, the resulting search filter will be (&(posixid=*)(cn=Babs Jenson)).

An optional parameter can be added to allow the LDAP Url to override the connection type. This parameter can be one of the following:

NONE
Establish an unsecure connection on the default LDAP port. This is the same as ldap:// on port 389.
SSL
Establish a secure connection on the default secure LDAP port. This is the same as ldaps://
TLS | STARTTLS
Establish an upgraded secure connection on the default LDAP port. This connection will be initiated on port 389 by default and then upgraded to a secure connection on the same port.

See above for examples of AuthLDAPURL URLs.

When AuthLDAPURL is enabled in a particular context, but some other module has performed authentication for the request, the server will try to map the username to a DN during authorization regardless of whether or not LDAP-specific requirements are present. To ignore the failures to map a username to a DN during authorization, set AuthzLDAPAutoritative to "off".

top

AuthzLDAPAuthoritative Directive

Description:Prevent other authentication modules from authenticating the user if this one fails
Syntax:AuthzLDAPAuthoritative on|off
Default:AuthzLDAPAuthoritative on
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_authnz_ldap

Set to off if this module should let other authorization modules attempt to authorize the user, should authorization with this module fail. Control is only passed on to lower modules if there is no DN or rule that matches the supplied user name (as passed by the client).

When no LDAP-specific Require directives are used, authorization is allowed to fall back to other modules as if AuthzLDAPAuthoritative was set to off.

mod/mod_authz_dbm.html100644 0 0 24766 11237400230 12515 0ustar 0 0 mod_authz_dbm - Apache HTTP Server
<-

Apache Module mod_authz_dbm

Description:Group authorization using DBM files
Status:Extension
ModuleIdentifier:authz_dbm_module
SourceFile:mod_authz_dbm.c
Compatibility:Available in Apache 2.1 and later

Summary

This module provides authorization capabilities so that authenticated users can be allowed or denied access to portions of the web site by group membership. Similar functionality is provided by mod_authz_groupfile.

top

AuthDBMGroupFile Directive

Description:Sets the name of the database file containing the list of user groups for authorization
Syntax:AuthDBMGroupFile file-path
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_authz_dbm

The AuthDBMGroupFile directive sets the name of a DBM file containing the list of user groups for user authorization. File-path is the absolute path to the group file.

The group file is keyed on the username. The value for a user is a comma-separated list of the groups to which the users belongs. There must be no whitespace within the value, and it must never contain any colons.

Security

Make sure that the AuthDBMGroupFile is stored outside the document tree of the web-server. Do not put it in the directory that it protects. Otherwise, clients will be able to download the AuthDBMGroupFile unless otherwise protected.

Combining Group and Password DBM files: In some cases it is easier to manage a single database which contains both the password and group details for each user. This simplifies any support programs that need to be written: they now only have to deal with writing to and locking a single DBM file. This can be accomplished by first setting the group and password files to point to the same DBM:

AuthDBMGroupFile /www/userbase
AuthDBMUserFile /www/userbase

The key for the single DBM is the username. The value consists of

Encrypted Password : List of Groups [ : (ignored) ]

The password section contains the encrypted password as before. This is followed by a colon and the comma separated list of groups. Other data may optionally be left in the DBM file after another colon; it is ignored by the authorization module. This is what www.telescope.org uses for its combined password and group database.

top

AuthzDBMAuthoritative Directive

Description:Sets whether authorization will be passed on to lower level modules
Syntax:AuthzDBMAuthoritative On|Off
Default:AuthzDBMAuthoritative On
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_authz_dbm

Setting the AuthzDBMAuthoritative directive explicitly to Off allows group authorization to be passed on to lower level modules (as defined in the modules.c file) if there is no group found for the supplied userID. If there are any groups specified, the usual checks will be applied and a failure will give an Authentication Required reply.

So if a userID appears in the database of more than one module; or if a valid Require directive applies to more than one module; then the first module will verify the credentials; and no access is passed on; regardless of the AuthAuthoritative setting.

A common use for this is in conjunction with one of the auth providers; such as mod_authn_dbm or mod_authn_file. Whereas this DBM module supplies the bulk of the user credential checking; a few (administrator) related accesses fall through to a lower level with a well protected .htpasswd file.

By default, control is not passed on and an unknown group will result in an Authentication Required reply. Not setting it thus keeps the system secure and forces an NCSA compliant behaviour.

Security

Do consider the implications of allowing a user to allow fall-through in his .htaccess file; and verify that this is really what you want; Generally it is easier to just secure a single .htpasswd file, than it is to secure a database which might have more access interfaces.

top

AuthzDBMType Directive

Description:Sets the type of database file that is used to store list of user groups
Syntax:AuthzDBMType default|SDBM|GDBM|NDBM|DB
Default:AuthzDBMType default
Context:directory, .htaccess
Override:AuthConfig
Status:Extension
Module:mod_authz_dbm

Sets the type of database file that is used to store the list of user groups. The default database type is determined at compile time. The availability of other types of database files also depends on compile-time settings.

It is crucial that whatever program you use to create your group files is configured to use the same type of database.

mod/mod_authz_default.html100644 0 0 12024 11237400230 13357 0ustar 0 0 mod_authz_default - Apache HTTP サーバ
<-

Apache モジュール mod_authz_default

説明:承認フォールバックモジュール
ステータス:Base
モジュール識別子:authz_default_module
ソースファイル:mod_authz_default.c
互換性:Apache 2.1 以降

概要

このモジュールは mod_authz_usermod_authz_groupfile といった承認モジュールを 設定しなかった場合のフォールバックモジュールとして設計されています。 どのような承認リクエストも単に拒否します。

ディレクティブ

top

AuthzDefaultAuthoritative ディレクティブ

説明:承認が低位のモジュールに渡されるかどうかを設定する
構文:AuthzDefaultAuthoritative On|Off
デフォルト:AuthzDefaultAuthoritative On
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Base
モジュール:mod_authz_default

AuthzDefaultAuthoritative ディレクティブを 明示的に Off に設定すると 認証を次の (modules.c ファイルで定義されている) 低位のモジュールに渡すことを許可します。

注意

mod_authz_default 自体がとても低い レベルとして定義されていますので、通常はこれよりも低次の モジュールは存在しません。ですから AuthDefaultAuthoritative はデフォルト (On) のままにしたほうが良いでしょう。

mod/mod_authz_groupfile.html100644 0 0 20567 11237400230 13742 0ustar 0 0 mod_authz_groupfile - Apache HTTP サーバ
<-

Apache モジュール mod_authz_groupfile

説明:プレーンテキストファイルを用いたグループ承認
ステータス:Base
モジュール識別子:authz_groupfile_module
ソースファイル:mod_authz_groupfile.c
互換性:Apache 2.1 以降

概要

このモジュールは認証されたユーザがグループのメンバーか 否かによってウェブサイトの一部へのアクセスを許可するか拒否するかの 承認機能を提供します。同様の機能は mod_authz_dbm によっても提供されています。

top

AuthGroupFile ディレクティブ

説明:証認に使用するユーザグループの一覧が格納されている、 テキストファイルの名前を設定する
構文:AuthGroupFile file-path
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Base
モジュール:mod_authz_groupfile

AuthGroupFile ディレクティブは、 証認に使用するユーザグループの一覧が格納されている、 テキストファイルの名前を設定します。 file-path はグループファイルへのパスです。 絶対パスでなければ、 ServerRoot からの相対パスとして扱われます。

グループファイル各行は、グループ名、コロン、そして スペース区切りでそのメンバーのユーザ名を記述します。

例:

mygroup: bob joe anne

大きなファイルを探索するのは、非常に効率が悪いという点に 注意してください。そのような場合は、 AuthDBMGroupFile の方がずっと良い性能を発揮します。

セキュリティ

AuthGroupFile は、 ウェブサーバのドキュメントツリーの外側に 保管するようにしてください。 保護しようとしているディレクトリ以下には、置かないで下さい。 そうしないとクライアントが AuthGroupFile を ダウンロードできてしまう可能性があります。

top

AuthzGroupFileAuthoritative ディレクティブ

説明:承認が下位のモジュールに渡されるかどうかを設定する
構文:AuthzGroupFileAuthoritative On|Off
デフォルト:AuthzGroupFileAuthoritative On
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Base
モジュール:mod_authz_groupfile

AuthzGroupFileAuthoritative ディレクティブを 明示的に Off に設定すると userID に対応する グループがない場合に、 (module.c で定義されている) 下位のモジュールにグループ承認を 渡すことを許可します。

デフォルトでは制御は渡されず、未知のグループの場合は Authentication Required 応答が返されます。ですから、これを設定しないと システムを安全に保つことができ、NCSA 互換の振る舞いをさせることになります。

セキュリティ

ユーザの .htaccess ファイルで他の承認手段への 委譲ができるようにすることの意味するところは十分に考慮しておいてください。 そしてそれが、本当に望む挙動であることを確かめてください。 通常は一つの .htpasswd ファイルを安全にする方が より多くのアクセスインタフェースを持つかもしれないデータベースを 安全にするよりも簡単です。

mod/mod_authz_host.html100644 0 0 47401 11237400230 12717 0ustar 0 0 mod_authz_host - Apache HTTP サーバ
<-

Apache モジュール mod_authz_host

This translation may be out of date. Check the English version for recent changes.
説明:ホスト (名前もしくは IP アドレス) に基づいたグループ承認
ステータス:Base
モジュール識別子:authz_host_module
ソースファイル:mod_authz_host.c
互換性:Apache 2.1 以降

概要

mod_authz_host により提供されるディレクティブは サーバの特定の部分への アクセスを制御するために <Directory>, <Files>, <Location>.htaccess ファイルで使用されます。クライアントのホスト名、IP アドレスや 環境変数として取得された、その他のリクエストの特徴に基づいて アクセス制御を行なうことができます。AllowDeny ディレクティブは どのようなクライアントにアクセスを 許可する、しないかを指定するために使用されます。一方、 Order ディレクティブは デフォルトのアクセス状態と、 Allow ディレクティブと Deny ディレクティブとのお互いへの影響の仕方を設定します。

ホストによるアクセス制限とパスワードによる認証を同時に 行なうことが可能です。その場合、その二つの制限の関係を指定するために Satisfy ディレクティブを使用します。

一般的には、アクセス制限ディレクティブはすべてのアクセスメソッド (GET, PUT, POST など) に適用されます。そして、ほとんどの場合これが望ましい動作です。 しかし、<Limit> セクションの中にディレクティブを書くことで、 一部のメソッドにのみ制限をかけることもできます。

ディレクティブ

参照

top

Allow ディレクティブ

説明:サーバのある領域にアクセスできるホストを制御する
構文: Allow from all|host|env=env-variable [host|env=env-variable] ...
コンテキスト:ディレクトリ, .htaccess
上書き:Limit
ステータス:Base
モジュール:mod_authz_host

Allow ディレクティブはどのホストが サーバのある領域をアクセスできるかに影響を与えます。 アクセスはホスト名、IP アドレス、IP アドレスの範囲や、 環境変数として取得された、その他のクライアントのリクエストの 特徴によって制御することができます。

このディレクティブの最初の引数は常に from です。 それに続く引数は三つの違った形式があります。Allow from all が指定されていれば、すべてのホストにアクセスを許可し、 アクセス制限は下で説明されているように、 Deny ディレクティブと Order ディレクティブの設定で決まります。 特定のホストやホスト群にのみサーバへのアクセスを許可するためには、 以下のどれかの形式で host を指定することができます:

ドメイン名 (の一部)

Allow from apache.org
Allow from .net example.edu

この文字列に合うか、これで終わる名前のホストのアクセスが許可されます。 各部分が完全に合うものだけに適用されますので、上の例は foo.apache.org にはマッチしますが、 fooapache.org にはマッチしません。 この設定をすると、Apache は HostnameLookups の設定に関わらず、クライアントの IP アドレスに対して DNS の 2 重逆引きを行ないます。 ホスト名からオリジナルの IP アドレスを順引きします。 順引きと逆引きが一致し、ホスト名が該当した場合にのみ、 アクセスが許可されます。

完全な IP アドレス

Allow from 10.1.2.3
Allow from 192.168.1.104 192.168.1.205

アクセスを許可する IP アドレスです。

IP アドレスの一部

Allow from 10.1
Allow from 10 172.20 192.168.2

サブネットの制限用の、IP アドレスの最初の一つから三つまでのバイトです。

ネットワーク/ネットマスク の対

Allow from 10.1.0.0/255.255.0.0

ネットワーク a.b.c.d とネットマスク w.x.y.z です。 より細粒度のサブネット制限用です。

ネットワーク/nnn CIDR 指定

Allow from 10.1.0.0/16

ネットマスクが nnn の上位ビットが 1 となっているものからなること以外は前のものと同じです。

注: 最後の三つの例はまったく同じホストに合います。

IPv6 アドレスと IPv6 のサブネットは以下のように指定できます:

Allow from 2001:db8::a00:20ff:fea7:ccea
Allow from 2001:db8::a00:20ff:fea7:ccea/10

Allow ディレクティブの引数の三つ目の形式は、 環境変数 の存在によりアクセスの制御を行なえるようにするものです。 Allow from env=env-variable が指定されていると、環境変数 env-variable が存在した場合にリクエストはアクセスを許可されます。サーバは mod_setenvif のディレクティブにより、クライアントのリクエスト の特徴に基づいて柔軟に環境変数を設定する機能を提供します。 ですから、このディレクティブはクライアントの User-Agent (ブラウザの種類)、Referer や他の HTTP リクエストのヘッダフィールドなどに基づいて アクセス許可をするために使うことができます。

Example:

SetEnvIf User-Agent ^KnockKnock/2\.0 let_me_in
<Directory /docroot>
Order Deny,Allow
Deny from all
Allow from env=let_me_in
</Directory>

この場合、user-agent の文字列が KnockKnock/2.0 で始まるブラウザのみがアクセスを許可され、 他のものはアクセスを拒否されます。

top

Deny ディレクティブ

説明:サーバがアクセスを拒否するホストを制御する
構文: Deny from all|host|env=env-variable [host|env=env-variable] ...
コンテキスト:ディレクトリ, .htaccess
上書き:Limit
ステータス:Base
モジュール:mod_authz_host

このディレクティブはホスト名、IP アドレス、環境変数に基づいてサーバへのアクセスを制限します。 Deny ディレクティブの引数は Allow ディレクティブとまったく同じです。

top

Order ディレクティブ

説明:デフォルトのアクセス可能な状態と、AllowDeny が評価される順番を制御する
構文: Order ordering
デフォルト:Order Deny,Allow
コンテキスト:ディレクトリ, .htaccess
上書き:Limit
ステータス:Base
モジュール:mod_authz_host

Order ディレクティブはデフォルトのアクセスの状態と Allow ディレクティブと Deny ディレクティブが評価される順番を制御します。 Ordering は以下のどれかです。

Deny,Allow
Deny ディレクティブが Allow ディレクティブの前に評価されます。 アクセスはデフォルトで許可されます。Deny ディレクティブに合わないか、Allow ディレクティブに合うクライアントはアクセスを許可されます。
Allow,Deny
Allow ディレクティブが Deny ディレクティブの前に評価されます。 アクセスはデフォルトで拒否されます。Allow ディレクティブに合わないか、Deny ディレクティブに合うクライアントはアクセスを拒否されます。
Mutual-failure
Allow のリストに現れて、 Deny のリストに現れないホストのみがアクセスを許可されます。 この順番付けは Order Allow,Deny と同じ効果を持ち、 その設定の方が好ましいために非推奨となっています。

キーワードはコンマで分離することだけが可能です。 間に空白があってはいけません。どの場合でも、AllowDeny 文は 全て評価されるということに注意してください。

以下の例では、apache.org ドメインのすべてのホストはアクセスを許可されます。 他のすべてのホストはアクセスを拒否されます。

Order Deny,Allow
Deny from all
Allow from apache.org

次の例では、foo.apache.org サブドメインにあるホスト以外の、 apache.org ドメインのすべてのホストがアクセスを許可されます。 apache.org ドメインでないホストは、デフォルトの状態がアクセス拒否のため、 サーバへのアクセスを拒否されます。

Order Allow,Deny
Allow from apache.org
Deny from foo.apache.org

一方、上の例の OrderDeny,Allow に変わっていれば、すべのホストにアクセスが許可されます。 これは、設定ファイル中の実際の順番に関わらず、 Allow from apache.org が最後に評価されて、 Deny from foo.apache.org を上書きするからです。 apache.org ドメインにないホストも、デフォルトの状態が allow に変化するために、アクセスを許可されます。

Order ディレクティブはデフォルトのアクセスの状態に影響を与えるので、 Allow ディレクティブと Deny ディレクティブが無くても、サーバのアクセスに影響を与えることができます。 たとえば、

<Directory /www>
Order Allow,Deny
</Directory>

はデフォルトのアクセス状態が deny になるため、 /www ディレクトリへのすべてのアクセスを拒否します。

Order ディレクティブはサーバの設定処理の各段階でだけ アクセスディレクティブの処理の順番を変更します。これは、たとえば、 Order ディレクティブの設定に関わらず、 <Location> セクションの Allow ディレクティブや Deny ディレクティブは、 Directory セクションや .htaccess ファイルの Allow ディレクティブや Deny ディレクティブよりも常に後に評価されるということを意味します。 設定セクションのマージの詳細については、 Directory,Location, Files セクションの動作方法 を参照してください。

mod/mod_authz_owner.html100644 0 0 26635 11237400230 13102 0ustar 0 0 mod_authz_owner - Apache HTTP サーバ
<-

Apache モジュール mod_authz_owner

説明:ファイルの所有者に基づいた承認
ステータス:Extension
モジュール識別子:authz_owner_module
ソースファイル:mod_authz_owner.c
互換性:Apache 2.1 以降で使用可能

概要

このモジュールはリクエストされたファイルのファイルシステムの 所有者やグループを HTTP 認証に使われたユーザ ID (ウェブユーザ ID) と 比較することでアクセスを承認します。提供されたユーザ名とパスワードは mod_auth_basicmod_auth_digest のような認証モジュールで既に 適切に検証されている必要があります。mod_authz_owner は以下のように、Require ディレクティブの file-ownerfile-group という二つの引数を認識します:

file-owner
提供されたウェブユーザ名はリクエストされたファイルの所有者の システムにおける名前と一致する必要があります。つまり、オペレーティング システムがファイルは jones により所有されている と言ったときは、ウェブからのアクセスに使われるユーザ名も jones でなければなりません。
file-group
ファイルを所有するシステムのグループの名前が、例えば mod_authz_groupfilemod_authz_dbm により提供されるグループデータベースに存在していて、 ウェブユーザ名がそのグループに属していなければなりません。 例えば、オペレーティングシステムがファイルは (システムの) グループ accounts により所有されていると言ったときは、 accounts がグループデータベースに存在して、 リクエストに使用されたウェブユーザ名がそのグループに属している 必要があります。

ファイルシステムに実際には存在しないリソース (つまり バーチャルなリソース) の承認に mod_authz_owner が使用されたときは、 アクセスは拒否されます。

特に、コンテント ネゴシエーションされた"MultiViews" のリソースは 決して承認しません。

ディレクティブ

トピック

参照

top

設定例

Require file-owner

複数ユーザのシステムで Apache ウェブサーバが実行されていて、 ~/public_html/private に各ユーザがファイルを置いているとします。 AuthDBMUserFile データベースが一つだけあり、すべてのウェブユーザ名が列挙されており、 このユーザ名がサーバで実際にファイルを所有しているユーザ名と一致している場合、 次の節のような設定で、ユーザが自分自身のファイルにアクセスできるようになります。 /home/smith/public_html/private の中のファイルは、所有者が smith の代わりに jones になっていない限り、 jones にはアクセスは許可されません。

<Directory /home/*/public_html/private>
AuthType Basic
AuthName MyPrivateFiles
AuthBasicProvider dbm
AuthDBMUserFile /usr/local/apache2/etc/.htdbm-all
Satisfy All
Require file-owner
</Directory>

Require file-group

上記のようなシステムで、数人のユーザがプロジェクトのファイルを ~/public_html/project-foo で共有しているとします。 ファイルはシステムのグループ foo に所有されていて、 AuthDBMGroupFile データベースが一つだけあり、そこにすべてのウェブユーザ名と グループのメンバが列挙されている、つまり、それらの ユーザは少なくとも foo というグループに属している、とします。 jonessmith の二人共がグループ foo のメンバである場合、どちらの人も両方の project-foo にアクセスが許可されます。

<Directory /home/*/public_html/project-foo>
AuthType Basic
AuthName "Project Foo Files"
AuthBasicProvider dbm

# combined user/group database
AuthDBMUserFile /usr/local/apache2/etc/.htdbm-all
AuthDBMGroupFile /usr/local/apache2/etc/.htdbm-all

Satisfy All
Require file-group
</Directory>

top

AuthzOwnerAuthoritative ディレクティブ

説明:承認が下位承認モジュールに渡されるかどうかを設定する
構文:AuthzOwnerAuthoritative On|Off
デフォルト:AuthzOwnerAuthoritative On
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Extension
モジュール:mod_authz_owner

AuthzOwnerAuthoritative ディレクティブを 明示的に Off に設定すると、以下の場合に認証が (modules.c で定義されている) 下位のモジュールに 渡されるようにします:

  • file-owner の場合は、提供されたウェブユーザ名に ファイルシステムの所有者が一致しないか、所有者がわからない場合。
  • file-group の場合は、提供されたウェブユーザ名が ファイルシステムグループに存在しないか、わからない場合。

値を Off に設定すると、file-ownerfile-group を組み合わせることもできるようになり、 その場合はどちらか (両方でも) にマッチした場合にアクセスを許可されます。

デフォルトでは制御は渡されず、未知のグループの場合は Authentication Required 応答が返されます。ですから、Off に設定しないことで システムを安全に保つことができ、NCSA 互換の振る舞いをさせることになります。

mod/mod_authz_user.html100644 0 0 12533 11237400230 12716 0ustar 0 0 mod_authz_user - Apache HTTP サーバ
<-

Apache モジュール mod_authz_user

This translation may be out of date. Check the English version for recent changes.
説明:ユーザ承認
ステータス:Base
モジュール識別子:authz_user_module
ソースファイル:mod_authz_user.c
互換性:Apache 2.1 以降で使用可能

概要

このモジュールは、認証されたユーザにウェブサイトの一部への アクセスを許可したり拒否したりするための承認機能を提供します。 mod_authz_user は認証されたユーザが Require user ディレクティブに書かれていれば アクセスを認めます。認証に成功したユーザすべてにアクセスを 許可するには、代わりに require valid-user を 使うことができます。

ディレクティブ

参照

top

AuthzUserAuthoritative ディレクティブ

説明:承認が下位のモジュールに渡されるかどうかを設定する
構文:AuthzUserAuthoritative On|Off
デフォルト:AuthzUserAuthoritative On
コンテキスト:ディレクトリ, .htaccess
上書き:AuthConfig
ステータス:Base
モジュール:mod_authz_user

AuthzUserAuthoritative ディレクティブを 明示的に Off に設定すると userID に対応する グループがない場合に、 (module.c で定義されている) 下位のモジュールにグループ承認を 渡すことを許可します。

デフォルトでは制御は渡されず、未知のグループの場合は Authentication Required 応答が返されます。ですから、これを設定しないと システムを安全に保つことができ、NCSA 互換の振る舞いをさせることになります。

mod/mod_autoindex.html100644 0 0 161426 11237400230 12553 0ustar 0 0 mod_autoindex - Apache HTTP サーバ
<-

Apache モジュール mod_autoindex

This translation may be out of date. Check the English version for recent changes.
説明:Unix の ls コマンドや Win32 の dir シェルコマンドに似た ディレクトリインデックスを生成する
ステータス:Base
モジュール識別子:autoindex_module
ソースファイル:mod_autoindex.c

概要

ディレクトリのインデックスは二つの情報源のうちの 一つから生成できます:

  • 普通は index.html と呼ばれる ユーザによって書かれたファイル。 DirectoryIndex ディレクティブでこのファイル名を設定します。 これは mod_dir で制御されます。
  • もしくは、サーバによって生成された一覧。 その他のディレクティブでこの一覧の書式を制御します。 AddIcon, AddIconByEncodingAddIconByType を使うことで、様々なファイルタイプに対してアイコン一覧を セットします。つまり、リストされたファイル毎に、 ファイルにマッチした一番最初のアイコンが表示されます。 これらは mod_autoindex で制御されます。

望むならば、自動インデックス生成を完全に除去 (あるいは置換) できるように、この二つの機能は分離されています。

自動インデックス生成は Options +Indexes を使うことで有効になります。詳細については、 Options ディレクティブをご覧下さい。

もし FancyIndexingオプションが IndexOptions ディレクティブに与えられているならば、 列の先頭は表示の順番を制御するリンクになります。 先頭のリンクを選択すると、一覧は再生成されて その列の値でソートされます。 同じ先頭を続けて選択すると、交互に昇順と降順とになります。 これらの列の先頭のリンクは、 IndexOptions ディレクティブの SuppressColumnSorting オプションで消すことができます。

"Size" でソートした場合は、用いられるのは 実際のファイルのサイズであって、 表示の値ではないことに注意してください - たとえ両方ともが "1K" と表示されていたとしても、 1010 バイトのファイルは必ず 1011 バイトのファイルよりも前 (昇順の場合) に表示されます。

top

Autoindex リクエストクエリー引数

Apache 2.0.23 で、 コラムソートのためにクエリー引数を再編成して、 新しいクエリーオプションのグループを導入しました。 出力に対するクライアントのすべての制御を効率的に抹消 できるように、 IndexOptions IgnoreClient が導入されました。

コラムソートのヘッダそれ自体が、 下記のソートクエリーオプションを付加する 自分自身を参照するリンクです。 下記のオプションのどれでも、 ディレクトリリソースへのリクエストに加えることができます。

  • C=N は、ファイル名でソートします。
  • C=M は、更新日時、 ディレクトリ、ファイル名の順でソートします。
  • C=S は、サイズ、 ディレクトリ、ファイル名の順でソートします。
  • C=D は、説明、 ディレクトリ、ファイル名の順でソートします。
  • O=A は、昇順で表をソートします。
  • O=D は、降順で表をソートします。
  • F=0 は、単純な表の書式にします。 (FancyIndex ではありません。)
  • F=1 は、FancyIndex 表示の表の書式にします。
  • F=2 は、表を HTML のテーブルを使った FancyIndex の書式にします。
  • V=0 は、バージョンによるソートを無効にします。
  • V=1 は、バージョンによるソートを有効にします。
  • P=pattern は、与えられた pattern に適合したファイルのみを表示します。

"P (パターンの P)" クエリー引数は、 通常の IndexIgnore ディレクティブが処理されたに検査され、 ファイル名全てが、他の autoindex リスト処理と同様の判定基準下に置かれ続ける ことに注意してください。 mod_autoindex のクエリー引数パーサ (解析) は、 認識不能なオプションにぶつかると即座に停止します。 クエリー引数は上の表に従って 正しい形式になっていなければなりません。

下の単純な例は、これらのクエリーオプションを 表します。これをそのまま切り取って HEADER.html ファイルに保存することもできます。 mod_autoindex が X=Go 入力にぶつかる前に 引数が全て解釈されるように、 未知の引数 "X" はリストの最後に置かれています。

<form action="" method="get">
Show me a <select name="F">
<option value="0"> Plain list</option>
<option value="1" selected="selected"> Fancy list</option>
<option value="2"> Table list</option>
</select>
Sorted by <select name="C">
<option value="N" selected="selected"> Name</option>
<option value="M"> Date Modified</option>
<option value="S"> Size</option>
<option value="D"> Description</option>
</select>
<select name="O">
<option value="A" selected="selected"> Ascending</option>
<option value="D"> Descending</option>
</select>
<select name="V">
<option value="0" selected="selected"> in Normal order</option>
<option value="1"> in Version order</option>
</select>
Matching <input type="text" name="P" value="*" />
<input type="submit" name="X" value="Go" />
</form>

top

AddAlt ディレクティブ

説明:アイコンの代わりに 表示される、ファイル名で選択された代替テキスト
構文:AddAlt string file [file] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_autoindex

AddAlt は、FancyIndexing において、アイコンの代わりに表示する代替テキストを提供します。 file は、説明するファイルのファイル拡張子、 ファイル名の一部、ワイルドカード表現、完全なファイル名の どれかになります。 string に空白がある場合は引用符 ("') で囲む必要があります。 この文字列は、クライアントが画像を表示できない場合や 画像のロードを無効にしている場合や アイコンの取得に失敗したときに表示されます。

AddAlt "PDF file" *.pdf
AddAlt Compressed *.gz *.zip *.Z

top

AddAltByEncoding ディレクティブ

説明:アイコンの代わりに表示される、MIME 符号化方法で選択された 代替テキスト
構文:AddAltByEncoding string MIME-encoding [MIME-encoding] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_autoindex

AddAltByEncoding は、 FancyIndexing において、アイコンの代わりに表示する代替文字列を提供します。 MIME-encoding は有効な符号化、例えば x-compress です。 string に空白があるときは、引用符 ("') で囲む必要があります。 この文字列は、クライアントが画像を表示できない場合や 画像のロードを無効にしている場合や アイコンの取得に失敗したときに表示されます。

AddAltByEncoding gzip x-gzip

top

AddAltByType ディレクティブ

説明:アイコンの代わりに 表示される、MIME タイプで選択された代替テキスト
構文:AddAltByType string MIME-type [MIME-type] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_autoindex

AddAltByType は、 FancyIndexing において、アイコンの代わりに表示する代替文字列を設定します。 MIME-type は有効なタイプ、例えば text/html です。 string に空白があるときは、引用符 ("') で囲む必要があります。 この文字列は、クライアントが画像を表示できない場合や 画像のロードを無効にしている場合や アイコンの取得に失敗したときに表示されます。

AddAltByType 'plain text' text/plain

top

AddDescription ディレクティブ

説明:ファイルに対して表示する説明
構文:AddDescription string file [file] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_autoindex

FancyIndexing において、ファイルに対して表示する説明を設定します。 file は説明するファイルのファイル拡張子、 ファイル名の一部、ワイルドカード表現、完全なファイル名の どれかになります。 string は二重引用符 (") で囲まれます。

AddDescription "The planet Mars" /web/pics/mars.gif

通常のデフォルトの説明領域は 23 バイトの幅です。 IndexOptions SuppressIcon オプションで 6 バイト追加、 IndexOptions SuppressSize オプションで 7 バイト追加、 IndexOptions SuppressLastModified オプションで 19 バイト追加されます。 ですから、デフォルトの説明コラムの最大幅は 55 バイトになります。

このコラムの大きさを上書きしたり、 説明が無制限長でもよいようにするための詳細に関しては、 DescriptionWidth という IndexOptions のキーワードをご覧下さい。

警告

AddDescription で定義された説明テキストは、タグや文字列といった HTML マークアップを含むことができます。 もし、説明コラムの幅によってタグ付けされた要素が丸め込まれた (太字の語句の最後が切れるといった) 場合、 出力結果は、ディレクトリ一覧の残りの部分に影響を与えるでしょう。

top

AddIcon ディレクティブ

説明:ファイルに表示するアイコンを名前で選択
構文:AddIcon icon name [name] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_autoindex

FancyIndexing において、 name で終わるファイルの隣に表示するアイコンを設定します。 icon は、(% でエスケープされた) アイコンへの相対 URL か、他の書式 (alttext, url) です。 ここで alttext は、非グラフィカルブラウザ向けにアイコンに付けられたテキストタグです。

name は、ディレクトリに対応する ^^DIRECTORY^^ か、空白行に対応する ^^BLANKICON^^ (一覧が正しく表示されるために) か、 ファイル拡張子か、ワイルドカード表現か、ファイル名の一部か 完全なファイル名です。

AddIcon (IMG,/icons/image.xbm) .gif .jpg .xbm
AddIcon /icons/dir.xbm ^^DIRECTORY^^
AddIcon /icons/backup.xbm *~

もし可能なら、 AddIcon より AddIconByType を優先的に使うべきでしょう。

top

AddIconByEncoding ディレクティブ

説明:ファイルに表示するアイコンを MIME 符号化方法で選択
構文:AddIconByEncoding icon MIME-encoding [MIME-encoding] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_autoindex

FancyIndexing において、ファイルの隣に表示するアイコンを設定します。 icon は、(% でエスケープされた) アイコンへの相対 URL か、他の書式 (alttext, url) です。 ここで alttext は、非グラフィカルブラウザ向けにアイコンに付けられたテキストタグです。

MIME-encoding は、要求されたエンコードに該当する ワイルドカード表現です。

AddIconByEncoding /icons/compress.xbm x-compress

top

AddIconByType ディレクティブ

説明:ファイルの隣に表示するアイコンを MIME タイプによって選択
構文:AddIconByType icon MIME-type [MIME-type] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_autoindex

FancyIndexing において、ファイルの隣に表示するアイコンを設定します。 icon は、(% でエスケープされた) アイコンへの相対 URL か、他の書式 (alttext, url) です。 ここで alttext は、非グラフィカルブラウザ向けにアイコンに付けられたテキストタグです。

MIME-type は、要求されたタイプに該当する ワイルドカード表現です。

AddIconByType (IMG,/icons/image.xbm) image/*

top

DefaultIcon ディレクティブ

説明:特定のアイコンが何も設定されていない時に ファイルに表示するアイコン
構文:DefaultIcon url-path
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_autoindex

FancyIndexing において、 特定のアイコンがない場合にファイルに表示するアイコンを設定します。 url-path は、(% でエスケープされた) アイコンへの相対 URL です。

DefaultIcon /icon/unknown.xbm

top

HeaderName ディレクティブ

説明: インデックス一覧の先頭に挿入されるファイルの名前
構文:HeaderName filename
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_autoindex

HeaderName ディレクティブは、 インデックス一覧の先頭に挿入するファイルの名前を設定します。 Filename は取り込むファイルの名前です。

HeaderName HEADER.html

HeaderName も ReadmeName も両方とも現在は、filename をインデックスされているディレクトリに用いられた URI に対する相対 URI パスとして扱います。 filename がスラッシュで始まる場合は、 DocumentRoot からの相対パスとなります。

HeaderName /include/HEADER.html

filename は メジャーコンテントタイプが "text/*" (例えばtext/html, text/plain 等です。) のドキュメントとして解決 されなければなりません。これはつまり、 もし CGI スクリプトの実際のファイルタイプが 次のディレクティブのようにして実際の出力とは異なって text/html としてマークされている場合、 filename は CGI スクリプトを参照するかも知れない、 ということを意味します:

AddType text/html .cgi

Options MultiViews が 有効になっている場合は、 コンテントネゴシエーション が行なわれます。 もし filename が (CGI スクリプトでない) 静的な text/html ドキュメントで解決され、 options IncludesIncludesNOEXEC が有効になっている場合は、 ファイルはサーバーサイドインクルードで処理されます (mod_include ドキュメントを参照して下さい)。

もし HeaderName で指定されたファイルが HTML ドキュメントの開始部分 (<html>, <head>, 等) を含んでいたら、 IndexOptions +SuppressHTMLPreamble を設定して、これらのタグが繰り返されないようにしたいと思うでしょう。

top

IndexIgnore ディレクティブ

説明:ディレクトリ一覧を行なう際に無視すべき ファイルリストに追加
構文:IndexIgnore file [file] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_autoindex

IndexIgnore ディレクティブは、 ディレクトリの一覧を行う際に無視すべきファイルリストに追加します。 file は、 シェル形式のワイルドカード表現か完全なファイル名です。 IndexIgnore が複数ある場合は、無視するリストに追加が行われ、 置換は行われません。デフォルトではリストには . (カレントディレクトリ) が含まれています。

IndexIgnore README .htaccess *.bak *~

top

IndexOptions ディレクティブ

説明:ディレクトリインデックスの様々な設定項目
構文:IndexOptions [+|-]option [[+|-]option] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_autoindex

IndexOptions は、ディレクトリインデックスの挙動を指定します。 option は次のどれかです:

DescriptionWidth=[n | *] (2.0.23 以降)
DescriptionWidth キーワードは説明コラムの幅を文字数で指定することができます。
-DescriptionWidth (または非設定) で、 mod_autoindex が最適な幅を計算するようにできます。
DescriptionWidth=n で、コラム幅を n バイトに固定します。
DescriptionWidth=* は、最長の説明に合わせて必要な長さまでコラムを延ばします。
説明を丸め込んだ場合特有の危険については AddDescription セクションをお読み下さい。
FancyIndexing
飾り付きインデックスをオンにします。
FoldersFirst (2.0.23 以降)
このオプションが有効になった場合、サブディレクトリの一覧は 必ず最初に現われて、そのディレクトリの通常のファイルは その後に続きます。 一覧は基本的には、ファイルとディレクトリの二つの部分に分けられて、 それぞれは別々にソートされ、その後サブディレクトリを先にして 表示が行なわれます。例えばソート順が名前の降順になっていて、 FoldersFirst が有効になっている場合は、 サブディレクトリ Zed はサブディレクトリ Beta よりも前にリストされ、通常のファイル GammaAlpha よりも前にリストされます。このオプションは FancyIndexing も有効になっているときにのみ、効果があります。
HTMLTable (実験的、 Apache 2.0.23 以降)
この実験的なオプションは FancyIndexing とともに指定することで、 飾りの付いたディレクトリ一覧のためにテーブルを使った単純な表を作ります。 これは古いブラウザを混乱させるかもしれないことに注意してください。 WinNT やその他 utf-8 が有効なプラットホームのように、ファイル名や説明テキストが 右読みになったり左読みになりえる場合は特に必要です。
IconsAreLinks
これは、FancyIndexing において、 アイコンもファイル名へのリンクの一部にします。
IconHeight[=pixels]
このオプションが、IconWidth とともに使われている場合は、 サーバはファイルアイコンのための img タグに heightwidth 属性を取り込むようになります。 これによって、イメージ全てをロードし終わるまで待たなくても、 ブラウザはページレイアウトをあらかじめ計算することができます。 このオプションに何も値が与えられなければ、Apache ソフトウェアで提供されているアイコンの標準の高さが デフォルトなります。
IconWidth[=pixels]
このオプションが、IconHeight とともに使われている場合は、 サーバはファイルアイコンのための img タグに heightwidth 属性を取り込むようになります。 これによって、イメージ全てをロードし終わるまで待たなくても、 ブラウザはページレイアウトをあらかじめ計算することができます。 このオプションに何も値が与えられなければ、Apache ソフトウェアで提供されているアイコンの標準の高さが デフォルトなります。
IgnoreCase
このオプションが有効であると、ファイル名は大文字小文字を区別せずにソートされます。 例えばファイル名が昇順でソートされ、IgnoreCase が有効であれば、 Zeta は alfa の後にリストされます (注意: GAMMA は常に gamma の前になります)。
IgnoreClient
このオプションで mod_autoindex は、 クライアントからの全てのクエリー変数を無視するようになります。 これはソート順も含みます。 (つまり SuppressColumnSorting を暗に意味します。)
NameWidth=[n | *]
NameWidth キーワードでファイル名コラムの幅をバイト数で 指定できます。
-NameWidth (または非設定) で、 mod_autoindex が最適な幅を計算するようにできます。
NameWidth=n で、コラム幅を n バイトに固定します。
NameWidth=* は、必要な長さまでコラムを延ばします。
ScanHTMLTitles
FancyIndexing のために、 HTML ドキュメントからタイトルを取り出すことを可能にします。 もしファイルに AddDescription で説明が与えられていなければ、 httpd は title タグの値を読むためにドキュメントを読み始めます。 これは CPU や disk に負荷をかけます。
ShowForbidden
指定した場合であっても、サブリクエストの結果が HTTP_UNAUTHORIZED や HTTP_FORBIDDEN のファイルは通常通り隠された状態のまま、 ファイル一覧が生成されます。
SuppressColumnSorting
もし指定されていれば、Apache は FancyIndexing で表示されているディレクトリ一覧での コラムの先頭を、ソートのためのリンクにしなくなります。 デフォルトの挙動は、リンクとします。 コラムの先頭を選ぶとコラムの値に従ってディレクトリリストを ソートします。 Apache 2.0.23 以前では、これは同時に ソート文字列のためのクエリー引数の解析も無効にします。 この挙動は Apache 2.0.23 では IndexOptions IgnoreClient で制御されるようになっています。
SuppressDescription
これは FancyIndexing におけるファイルの説明を消去します。 デフォルトでは、説明は定義されておらず、 このオプションを使うと他のために 23 文字の空白を稼ぐことができます。 ファイルの説明に関する情報は、 AddDescription をご覧下さい。また、説明のコラムサイズを制限する DescriptionWidth インデックスオプションもご覧下さい。
SuppressHTMLPreamble
通常、 HeaderName ディレクティブで指定したファイルを ディレクトリが実際に含んでいれば、標準的な HTML プリアンブル (<html>, <head>, ) の後に、 モジュールはファイルの中身をインクルードします。 SuppressHTMLPreamble オプションは、 この挙動を無効にできて、 モジュールがヘッダーファイルの中身から表示を始めます。 この場合、ヘッダーファイルは正しい HTML 命令を含んでいなければなりません。 ヘッダーファイルが存在しない場合は、プリアンブルは通常通り 生成されます。
SuppressIcon (Apache 2.0.23 以降)
これは FancyIndexing の一覧からアイコンを消去します。 SuppressIconSuppressRules と組合わせることによって正しい HTML 3.2 の出力が得られます。 正しい HTML 3.2 出力は、最終規格において imghrpre ブロックに入る (FancyIndexing 一覧で書式に使われています) ことを禁止しています。
SuppressLastModified
FancyIndexing 一覧において最終更新日時の表示を消去します。
SuppressRules (Apache 2.0.23 以降)
ディレクトリ一覧において水平区切り線 (hr タグ) を消去します。 SuppressIconSuppressRules と組合わせることによって正しい HTML 3.2 の出力が得られます。 正しい HTML 3.2 出力は、最終規格において imghrpre ブロックに入る (FancyIndexing 一覧で書式に使われています) ことを禁止しています。
SuppressSize
FancyIndexing 一覧においてファイルサイズの表示を消去します。
TrackModified (Apache 2.0.23 以降)
これは HTTP ヘッダ中に、 リストされたディレクトリの最終更新日や ETag 値を含めます。 これは、オペレーティングシステムやファイルシステムが 適切な stat() の返り値を返す場合にのみ有効です。 いくつかの UNIX システム、OS2 の JFS や Win32 の NTFS ボリュームはそうなっています。 例えば、OS2 と Win32 FAT ボリュームはそうではありません。 この機能が有効になると、クライアントやプロキシは HEAD リクエストを行うことによって、 ファイル一覧の変化を追跡することができるようになります。 いくつかのオペレーティングシステムは、新規ファイルや 移動ファイルは正しく追跡するけれども、 ディレクトリ中のファイルのサイズや日付は追跡しないということに 注意してください。 既に存在するファイルのサイズや日付のスタンプが変化しても、 全ての Unix プラットホームでは、 最終更新日ヘッダーを更新しません。 もしこれが重要であれば、 このオプションを無効のままにしてください。
VersionSort (Apache 2.0a3 以降)
VersionSort キーワードはバージョン番号を含んだファイルが 自然な方法でソートされるようにします。 文字列は通常通りソートされ、 それ以外の、説明や名前中の数となる部分文字列は その数値で比較されます。

例:

foo-1.7
foo-1.7.2
foo-1.7.12
foo-1.8.2
foo-1.8.2a
foo-1.12

番号が 0 から始まる場合は、端数と考えられます

foo-1.001
foo-1.002
foo-1.030
foo-1.04

XHTML (Apache 2.0.49 以降)
XHTML キーワードを指定すると、mod_autoindex は HTML 3.2 の代わりに XHTML 1.0 のコードを出力するようになります。
増減指定できる IndexOptions

Apache 1.3.3 では、 IndexOptions ディレクティブの扱いで幾つかの大きな変化が導入されました。 特に、

  • 一つのディレクトリに対する複数の IndexOptions ディレクティブは、現在では一つにマージされます。 上の例の結果は、

    <Directory /foo> IndexOptions HTMLTable
    IndexOptions SuppressColumnsorting
    </Directory>

    と同一になります。

    IndexOptions HTMLTable SuppressColumnsorting

  • 増減構文 (すなわち、'+' や '-' の接頭辞が付くキーワード) の追加。

'+' や '-' 接頭辞の付いたキーワードに出会うとそれは、 その時点での IndexOptions の設定 (これは上流のディレクトリを受け継ぎます) に対して適応されます。 しかしながら、接頭辞の付かないキーワードが処理された場合は、 受け継いだオプション全てとそれまで出会った増減設定全てが 消去されます。次の例を考えてみてください:

IndexOptions +ScanHTMLTitles -IconsAreLinks FancyIndexing
IndexOptions +SuppressSize

中身の効果は IndexOptions FancyIndexing +SuppressSize と同一です。 接頭辞の付かない FancyIndexing でそれ以前の増減キーワードを無効にされて、 その後の累積が始まるからです。

無条件に IndexOptions をあるディレクトリで設定することによって 継承した設定を消去して、+- 接頭辞の付かないキーワードで設定してください。

top

IndexOrderDefault ディレクティブ

説明: ディレクトリインデックスの標準の順番付けを設定
構文:IndexOrderDefault Ascending|Descending Name|Date|Size|Description
デフォルト:IndexOrderDefault Ascending Name
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_autoindex

IndexOrderDefault ディレクティブは FancyIndexing インデックスオプションと併せて用いれれます。 デフォルトでは、FancyIndexing のディレクトリ一覧はファイル名の昇順で表示されます。 IndexOrderDefault で、初期状態の表示順番を変えることができます。

IndexOrderDefault は二つの引数をとります。一つ目はソートの方向を指示する AscendingDescending のいずれかです。 二つ目の引数は Name, Date, SizeDescription のいずれか一つのキーワードであって、プライマリキーを指定します。 二つ目のキーは常にファイル名の昇順になります。

このディレクティブと SuppressColumnSorting インデックスオプションとを組み合わせることで、 ディレクトリ一覧をある特定の順番でのみ表示するようにできます。 これは、 クライアントが別の順番でディレクトリ一覧をリクエストすることを防ぎます。

top

IndexStyleSheet ディレクティブ

説明:ディレクトリインデックスに CSS スタイルシートを追加する
構文:IndexStyleSheet url-path
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_autoindex

IndexStyleSheet ディレクティブは インデックス表示に使用される CSS のファイル名を設定します。

IndexStyleSheet "/css/style.css"

top

ReadmeName ディレクティブ

説明:インデックス一覧の最後に挿入されるファイルの名前
構文:ReadmeName filename
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_autoindex

ReadmeName ディレクティブは、 インデックスの終わりに付け加えられるファイルの名前を設定します。 filename は挿入するファイルの名前で、 一覧の行われている位置から相対的なものとして解釈されます。 filename がスラッシュで始まる場合は、 DocumentRoot からの相対パスとなります。

ReadmeName FOOTER.html

例 2

ReadmeName /include/FOOTER.html

より詳細にまでこの挙動について記述している HeaderName もご覧下さい。

mod/mod_cache.html100644 0 0 77454 11237400230 11605 0ustar 0 0 mod_cache - Apache HTTP サーバ
<-

Apache モジュール mod_cache

This translation may be out of date. Check the English version for recent changes.
説明:URI をキーにしたコンテンツのキャッシュ
ステータス:Extension
モジュール識別子:cache_module
ソースファイル:mod_cache.c

概要

使用方法については注意する必要があり、 AllowDeny ディレクティブを迂回する設定もできてしまいます。 ホスト名やアドレスや環境変数に基づいてクライアントからの アクセスを制限したい場合は、キャッシュ機能を有効にすべきでは ありません。

mod_cache はローカルのコンテンツやプロキシされた コンテンツをキャッシュするために使われる RFC 2616 準拠の HTTP コンテンツキャッシュを実装しています。mod_cache の動作にはストレージを管理するモジュールが必要です。標準 Apache 配布には二つストレージ管理モジュールが含まれています:

mod_disk_cache
ディスクを使用したストレージ管理機構を実装しています。
mod_mem_cache
メモリを使用したストレージ管理機構を実装しています。 mod_mem_cache は次の二つのモードのどちらかで動作する ように設定できます: オープンされているファイル記述子をキャッシュするモードか、 ヒープ上でのオブジェクトの自体をキャッシュをするモードです。 mod_mem_cache はローカルで生成されるコンテンツや、 mod_proxyProxyPass を使って設定されている ときの (つまりリバースプロキシ での) バックエンドサーバの コンテンツをキャッシュするのに使えます。

コンテンツのキャッシュへの保存と取得は URI に基づいたキーが使われます。 アクセス保護のかけられているコンテンツはキャッシュされません。

詳細や解説、例については Caching Guide を参照して下さい。

top
top

サンプル設定

Sample httpd.conf

#
# Sample Cache Configuration
#
LoadModule cache_module modules/mod_cache.so

<IfModule mod_cache.c>
#LoadModule disk_cache_module modules/mod_disk_cache.so
# If you want to use mod_disk_cache instead of mod_mem_cache,
# uncomment the line above and comment out the LoadModule line below.
<IfModule mod_disk_cache.c>
CacheRoot c:/cacheroot
CacheEnable disk /
CacheDirLevels 5
CacheDirLength 3
</IfModule>

LoadModule mem_cache_module modules/mod_mem_cache.so
<IfModule mod_mem_cache.c>
CacheEnable mem /
MCacheSize 4096
MCacheMaxObjectCount 100
MCacheMinObjectSize 1
MCacheMaxObjectSize 2048
</IfModule>

# When acting as a proxy, don't cache the list of security updates
CacheDisable http://security.update.server/update-list/
</IfModule>

top

CacheDefaultExpire ディレクティブ

説明:期日が指定されていないときにドキュメントをキャッシュするデフォルトの期間
構文:CacheDefaultExpire seconds
デフォルト:CacheDefaultExpire 3600 (1時間)
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_cache

CacheDefaultExpire ディレクティブは、ドキュメントに 有効期限 (expiry) や最終修正時刻 (last-modified) が指定されていない場合の デフォルトの時間を指定します。CacheMaxExpire ディレクティブで指定された値はこの設定を上書きしません

CacheDefaultExpire 86400

top

CacheDisable ディレクティブ

説明:特定の URL をキャッシュしない
構文:CacheDisable url-string
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_cache

CacheDisable ディレクティブで mod_cache モジュールが url-string 以下の URL をキャッシュしないようにします。

CacheDisable /local_files

top

CacheEnable ディレクティブ

説明:指定したストレージ管理方式を使ってのキャッシュを有効にする
構文:CacheEnable cache_type url-string
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_cache

CacheEnable ディレクティブで mod_cache モジュールが url-string 以下の URL をキャッシュするようにします。 キャッシュストレージ管理方式は cache_type 引数で指定します。 cache_type mem で、 mod_mem_cache で実装されているメモリを使ったストレージ 管理方式を使うように mod_cache に指示します。 cache_type disk で、 mod_disk_cache で実装されているディスクを使ったストレージ 管理を使うように mod_cache に指示します。 cache_type fdmod_cachemod_mem_cache により実装されているファイル記述子の キャッシュを使うように指示します。

(下の例のように) CacheEnable ディレクティブの URL 空間が重複しているときは、該当するストレージ方式を順に試して、 実際にリクエストの処理ができると、その方式で処理します。 ストレージ管理方式が実行される順番は設定ファイル中の CacheEnable の順番により決定されます。

CacheEnable mem /manual
CacheEnable fd /images
CacheEnable disk /

フォワードプロクシサーバとして動作させる場合は、 url-string でリモートサイトとプロクシするプロトコルを 指定して、何に対してキャッシュを有効にするか指定することもできます。

# Cache proxied url's
CacheEnable disk /

# Cache FTP-proxied url's
CacheEnable disk ftp://

# Cache content from www.apache.org
CacheEnable disk http://www.apache.org/

top

CacheIgnoreCacheControl ディレクティブ

説明:キャッシュされているコンテンツを返さないようにクライアントから リクエストされても無視する
構文:CacheIgnoreCacheControl On|Off
デフォルト:CacheIgnoreCacheControl Off
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_cache

Cache-Control: no-cache ヘッダや Pragma: no-store ヘッダのあるリクエストに 対しては、通常キャッシュを使いません。CacheIgnoreCacheControl ディレクティブを使うと、この動作を上書きできます。 CacheIgnoreCacheControl On とすると、 リクエストに no-cache という値があっても、キャッシュを使ってドキュメントを 返すようになります。認証を必要とするドキュメントは決して キャッシュされません。

CacheIgnoreCacheControl On

警告

このディレクティブを使うと、ドキュメント取得時にキャッシュを使わないように クライアントがリクエストしているにもかかわらず、キャッシュを 使うようになります。その結果、 古いコンテンツが送られ続けることになってしまうかもしれません。

参照

top

CacheIgnoreHeaders ディレクティブ

説明:指定された HTTP ヘッダをキャッシュに保存しない。
構文:CacheIgnoreHeaders header-string [header-string] ...
デフォルト:CacheIgnoreHeaders None
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_cache

RFC 2616 によると、hop-by-hop HTTP ヘッダはキャッシュには保管されません。 以下のヘッダは hop-by-hop ヘッダに該当しますので、 CacheIgnoreHeaders の設定に関係なくキャッシュには保管されません:

  • Connection
  • Keep-Alive
  • Proxy-Authenticate
  • Proxy-Authorization
  • TE
  • Trailers
  • Transfer-Encoding
  • Upgrade

CacheIgnoreHeaders で キャッシュに保管しない追加の HTTP ヘッダを指定します。 例えば、クッキーをキャッシュに保管しないようにした方がよい場合も あるでしょう。

CacheIgnoreHeaders の引数は、 キャッシュに保管しない HTTP ヘッダを空白区切りにしたリスト形式です。 キャッシュに保管しないヘッダが hop-by-hop ヘッダだけの場合 (RFC 2616 準拠の動作のとき) は、 CacheIgnoreHeadersNone に設定できます。

例 1

CacheIgnoreHeaders Set-Cookie

例 2

CacheIgnoreHeaders None

警告:

Expires のような適切のキャッシュ管理のために必要な ヘッダが CacheIgnoreHeaders の設定により 保管されていないときは、mod_cache の動作は定義されていません。
top

CacheIgnoreNoLastMod ディレクティブ

説明:応答に Last Modified が無くても気にしないようにする
構文:CacheIgnoreNoLastMod On|Off
デフォルト:CacheIgnoreNoLastMod Off
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_cache

通常、Last-Modified による最終修正時刻の無いドキュメントはキャッシュ されません。(例えば mod_include による処理のときなどに) Last-Modified 時刻が消去されたり、そもそも最初から提供されていない 状況があります。CacheIgnoreNoLastMod ディレクティブを使うと、Last-Modified 日時が指定されていない ドキュメントでもキャッシュするように指定できます。ドキュメントに 最終修正時刻 (Last-Modified) 有効期限 (expiry) がない場合は、有効期限の 生成に CacheDefaultExpire が使われます。

CacheIgnoreNoLastMod On

top

CacheLastModifiedFactor ディレクティブ

説明:LastModified の日付に基づいて有効期限 (expiry) を計算するための重みを指定する
構文:CacheLastModifiedFactor float
デフォルト:CacheLastModifiedFactor 0.1
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_cache

ドキュメントに Last-Modified の日付が無いけれども有効期限 (expiry) の日付があるというときに、有効期限を最終修正時刻からの経過時間として 計算するようにできます。有効期限を次の計算式に従って生成するのですが、 そのときに使われる factorCacheLastModifiedFactor ディレクティブで指定します。

expiry-period = time-since-last-modified-date * factor expiry-date = current-date + expiry-period

例えば、ドキュメントが 10 時間前に最後に修正されていて、 factor が 0.1 であれば、期日は 10*0.1 = 1 時間に 設定されます。現在時刻が 3:00pm であれば、計算された期日は 3:00pm + 1hour = 4:00pm になります。

期日が CacheMaxExpire で設定されている値 より大きくなってしまっている場合は、CacheMaxExpire の設定値が優先されます。

CacheLastModifiedFactor 0.5

top

CacheMaxExpire ディレクティブ

説明:ドキュメントをキャッシュする最大時間を秒数で表したもの
構文:CacheMaxExpire seconds
デフォルト:CacheMaxExpire 86400 (一日)
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_cache

CacheMaxExpire ディレクティブは、 キャッシュする HTTP ドキュメントを、元のサーバに問い合わせないまま最大何秒 保持してもよいかを指定します。つまり、ドキュメントは最大でこの秒数間ぶん古く なることになります。この最大値は、(訳注:レスポンス中で)ドキュメントと共に ドキュメントの期日が提供されている場合でも適用されます。

CacheMaxExpire 604800

top

CacheStoreNoStore ディレクティブ

説明:no-store と指定されているレスポンスのキャッシュを試みる。
構文:CacheStoreNoStore On|Off
デフォルト:CacheStoreNoStore Off
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_cache

通常 Cache-Control: no-store ヘッダのついているレスポンスは キャッシュされません。CacheStoreNoCache ディレクティブでこの挙動を上書きできます。 CacheStoreNoCache On で no-store ヘッダのついている リソースに対してもキャッシュを試みるようになります。 ただし認証の求められるリソースは 決して キャッシュされません。

CacheStoreNoStore On

警告:

RFC 2616 に記載されているように no-store ディレクティブは、 "不注意による機密情報の漏洩や残留 (バックアップテープ等) を防ぐ" 目的で使われますが、このオプションを有効にすると、 機密情報を保持することになってしまいます。 ですので、ここで警告しておきます。

参照

top

CacheStorePrivate ディレクティブ

説明:private と指定されているレスポンスのキャッシュを試みる。
構文:CacheStorePrivate On|Off
デフォルト:CacheStorePrivate Off
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_cache

通常 Cache-Control: private ヘッダのついているレスポンスは キャッシュされません。CacheStorePrivate ディレクティブでこの挙動を上書きできます。 CacheStorePrivate On で private ヘッダのついている リソースに対してもキャッシュを試みるようになります。 ただし認証の求められるリソースは 決して キャッシュされません。

CacheStorePrivate On

警告:

上流サーバがキャッシュしないように指定してきても、 それを無視してキャッシュするようになります。 望ましい挙動になるのは、本当に 'private' なキャッシュについてのみでしょう。

参照

mod/mod_cern_meta.html100644 0 0 16652 11237400230 12470 0ustar 0 0 mod_cern_meta - Apache HTTP Server
<-

Apache Module mod_cern_meta

Description:CERN httpd metafile semantics
Status:Extension
ModuleIdentifier:cern_meta_module
SourceFile:mod_cern_meta.c

Summary

Emulate the CERN HTTPD Meta file semantics. Meta files are HTTP headers that can be output in addition to the normal range of headers for each file accessed. They appear rather like the Apache .asis files, and are able to provide a crude way of influencing the Expires: header, as well as providing other curiosities. There are many ways to manage meta information, this one was chosen because there is already a large number of CERN users who can exploit this module.

More information on the CERN metafile semantics is available.

top

MetaDir Directive

Description:Name of the directory to find CERN-style meta information files
Syntax:MetaDir directory
Default:MetaDir .web
Context:server config, virtual host, directory, .htaccess
Override:Indexes
Status:Extension
Module:mod_cern_meta

Specifies the name of the directory in which Apache can find meta information files. The directory is usually a 'hidden' subdirectory of the directory that contains the file being accessed. Set to "." to look in the same directory as the file:

MetaDir .

Or, to set it to a subdirectory of the directory containing the files:

MetaDir .meta

top

MetaFiles Directive

Description:Activates CERN meta-file processing
Syntax:MetaFiles on|off
Default:MetaFiles off
Context:server config, virtual host, directory, .htaccess
Override:Indexes
Status:Extension
Module:mod_cern_meta

Turns on/off Meta file processing on a per-directory basis.

top

MetaSuffix Directive

Description:File name suffix for the file containg CERN-style meta information
Syntax:MetaSuffix suffix
Default:MetaSuffix .meta
Context:server config, virtual host, directory, .htaccess
Override:Indexes
Status:Extension
Module:mod_cern_meta

Specifies the file name suffix for the file containing the meta information. For example, the default values for the two directives will cause a request to DOCUMENT_ROOT/somedir/index.html to look in DOCUMENT_ROOT/somedir/.web/index.html.meta and will use its contents to generate additional MIME header information.

Example:

MetaSuffix .meta

mod/mod_cgi.html100644 0 0 40003 11237400230 11260 0ustar 0 0 mod_cgi - Apache HTTP サーバ
<-

Apache モジュール mod_cgi

This translation may be out of date. Check the English version for recent changes.
説明:CGI スクリプトの実行
ステータス:Base
モジュール識別子:cgi_module
ソースファイル:mod_cgi.c

概要

Mime タイプが application/x-httpd-cgi であるか、ハンドラ cgi-script (Apache 1.1 以降) が指定されているファイルは CGI スクリプトとして扱われ、 サーバにより実行され、その出力がクライアントに返されます。 ファイルは、AddType ディレクティブに指定された 拡張子を名前に含むか、 ScriptAlias ディレクトリに存在することによりこのタイプになります。

サーバが CGI スクリプトを実行するときには、 DOCUMENT_ROOT と呼ばれる変数を環境に追加します。この変数は DocumentRoot の値を保持します。

Apache で CGI スクリプトを使用するためのイントロダクションは、 CGI による動的コンテンツ を参照してください。

Unix でマルチスレッドの MPM を使っている場合は、このモジュールの 代わりに mod_cgid を使う必要があります。 ユーザレベルではこの二つのモジュールは本質的には同一です。

top

CGI 環境変数

サーバは CGI 規格 で決められている CGI 環境変数を設定します。以下のものは、条件付きで設定されます。

PATH_INFO
これは AcceptPathInfo ディレクティブが明示的に off に設定されている場合は設定されません。デフォルトの、 AcceptPathInfo が 指定されていないときの振る舞いでは、mod_cgi はパス情報 (URI のスクリプトのファイル名の後に続く /more/path/info) を 受け付けますが、コアはサーバはパス情報のあるリクエストに 対して 404 NOT FOUND エラーを返します。AcceptPathInfo ディレクティブを 省略すると、mod_cgi へのリクエストに対して On を 設定したのと同じ効果になります。
REMOTE_HOST
HostnameLookupson (デフォルトでは off です) で、アクセスしているホストのアドレスの DNS の逆引きが実際にホスト名を見つけたときにのみ設定されます。
REMOTE_IDENT
IdentityCheckon に設定されていて、アクセスしているホストが ident プロトコルをサポートしているときにのみ設定されます。 これは簡単に偽ることができ、クライアントとサーバの間に プロキシがあればまったく役に立たないので、 この変数の値は信用できないということに注意してください。
REMOTE_USER
CGI スクリプトに認証が必要なときにのみ設定されます。
top

CGI のデバッグ

CGI スクリプトのデバッグは、正しく動作していないスクリプトの出力 (標準出力とエラー) を調べることができないために、難しい状態が続いていました。 これらの Apache 1.2 以降にある ディレクティブはより詳細なエラーのログ収集を提供します。

CGI ログファイルの書式

設定されているときには、CGI エラーログは適切に動作しないすべての CGI をログ収集します。それぞれの正しく動作しない CGI スクリプトは 複数の行にわたる情報がログ収集されます。最初の 2 行は常に以下の書式です:

%% [time] request-line
%% HTTP-status CGI-script-filename

エラーが、CGI スクリプトが実行できないというものである場合は、 ログファイルはさらにもう 2 行書かれます:

%%error
error-message

そうではなく、エラーが正しくないヘッダ情報を返す結果である場合 (スクリプトのバグであることがよくあります)、 以下の情報がログ収集されます:

%request
受け取ったすべての HTTP リクエストヘッダ
(もしあれば) POST や PUT の中身
%response
CGI スクリプトにより出力されたすべてのヘッダ
%stdout
CGI 標準出力
%stderr
CGI 標準エラー

(スクリプトが標準出力や標準エラーに何も出力しなかった場合は、 %stdout や %stderr はありません)。

top

ScriptLog ディレクティブ

説明:CGI スクリプトのエラーログファイルの場所
構文:ScriptLog file-path
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Base
モジュール:mod_cgi, mod_cgid

ScriptLog ディレクティブは CGI スクリプトの エラーログファイルを設定します。ScriptLog が 設定されていないときは、 エラーログは作成されません。設定されているときは、CGI のエラーはすべて引数として与えられているファイル名にログされます。 相対パスで指定されているときは、 ServerRootからの相対パスとして 扱われます。

ScriptLog logs/cgi_log

このログは子プロセスが実行されているユーザとしてオープンされます。 すなわちUser ディレクティブで指定された ユーザです。これは、スクリプトログが書かれるディレクトリがそのユーザで 書き込み可能か、スクリプトファイルが手動で作成され、そのユーザで 書き込み可能になっている必要があるということです。スクリプトログを アクセスログなどのためのログディレクトリに書かれるようにしたときは、 そのディレクトリを子プロセスを実行しているユーザの権限で 書き込み可能にはしないようにしてください。

スクリプトのログ収集は CGI スクリプトを書くときの デバッグ用の機能として意図されていて、通常のサーバで 常に使用されるようには意図されていないということに注意してください。 速度や効率は最適化されておらず、設計された以外の方法で使用されると セキュリティの問題があるかもしれません。

top

ScriptLogBuffer ディレクティブ

説明:スクリプトログに記録される PUT や POST リクエストの内容の上限
構文:ScriptLogBuffer bytes
デフォルト:ScriptLogBuffer 1024
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Base
モジュール:mod_cgi, mod_cgid

大きな本体を受け取ったときにログファイルがすぐに大きくなりすぎる 問題を避けるために、ファイルにログ収集される PUT と POST の本体の大きさは制限されています。デフォルトでは、1024 バイトまでがログ収集されますが、 このディレクティブはそれを変更することができます。

top

ScriptLogLength ディレクティブ

説明:CGI スクリプトのログファイルの大きさの上限
構文:ScriptLogLength bytes
デフォルト:ScriptLogLength 10385760
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Base
モジュール:mod_cgi, mod_cgid

ScriptLogLength は CGI スクリプトのログファイル の大きさを制限するために使用することができます。ログファイルは CGI のエラー毎に大量の情報 (リクエストのすべてのヘッダ、 すべての出力)をログしますので、すぐに大きなファイルになります。 この大きさの制限がないことによる問題を防ぐために、 このディレクティブを使って CGI のログファイルの 最大のファイルサイズを設定することができます。 ファイルがこの大きさを超えた場合は、それ以上は書き込まれません。

mod/mod_cgid.html100644 0 0 15434 11237400230 11436 0ustar 0 0 mod_cgid - Apache HTTP サーバ
<-

Apache モジュール mod_cgid

This translation may be out of date. Check the English version for recent changes.
説明:外部 CGI デーモンを使った CGI スクリプトの実行
ステータス:Base
モジュール識別子:cgid_module
ソースファイル:mod_cgid.c
互換性:Unix のスレッド MPM のみ

概要

最適化が施されていることと、以下で説明されている追加の ScriptSock ディレクティブを除いては、 mod_cgidmod_cgi と同様の 動作をします。Apache と CGI に関する詳細は mod_cgi の概要を読んでください。

Unix オペレーティングシステムの中には、マルチスレッドのサーバから プロセスを fork するのが非常にコストの高い動作になっているものがあります。 理由は、新しいプロセスが親プロセスのスレッドすべてを複製するからです。 各 CGI 起動時にこのコストがかかるのを防ぐために、mod_cgid は子プロセスを fork して CGI スクリプトを実行するための 外部デーモンを実行します。 主サーバは unix ドメインソケットを使ってこのデーモンと通信します。

コンパイル時にマルチスレッド MPM が選ばれたときは mod_cgi の代わりに必ずこのモジュールが使用されます。 ユーザのレベルではこのモジュールの設定と動作は mod_cgi とまったく同じです。唯一の例外は ScriptSock ディレクティブの 追加で、このディレクティブは CGI デーモンとの通信用のソケットの名前を 指定します。

top

ScriptSock ディレクティブ

説明:CGI デーモンとの通信に使われるソケットのファイル名の接頭辞
構文:ScriptSock file-path
デフォルト:ScriptSock logs/cgisock
コンテキスト:サーバ設定ファイル
ステータス:Base
モジュール:mod_cgid

このディレクティブは CGI デーモンとの通信に使われるソケットの ファイル名の接頭辞を設定します。また、ファイル名にはサーバのプロセスIDが 追加されます。ソケットは Apache が起動されたユーザ (通常 root) の パーミッションを用いてオープンされます。CGI スクリプトとの通信の セキュリティを保つために、ソケットの存在するディレクトリに 他のユーザが書き込み権限を持っていないようにすることが重要です。

ScriptSock /var/run/cgid.sock

mod/mod_charset_lite.html100644 0 0 27371 11237400230 13201 0ustar 0 0 mod_charset_lite - Apache HTTP Server
<-

Apache Module mod_charset_lite

Description:Specify character set translation or recoding
Status:Extension
ModuleIdentifier:charset_lite_module
SourceFile:mod_charset_lite.c

Summary

mod_charset_lite allows the server to change the character set of responses before sending them to the client. In an EBCDIC environment, Apache always translates HTTP protocol content (e.g. response headers) from the code page of the Apache process locale to ISO-8859-1, but not the body of responses. In any environment, mod_charset_lite can be used to specify that response bodies should be translated. For example, if files are stored in EBCDIC, then mod_charset_lite can translate them to ISO-8859-1 before sending them to the client.

This module provides a small subset of configuration mechanisms implemented by Russian Apache and its associated mod_charset.

top

Common Problems

Invalid character set names

The character set name parameters of CharsetSourceEnc and CharsetDefault must be acceptable to the translation mechanism used by APR on the system where mod_charset_lite is deployed. These character set names are not standardized and are usually not the same as the corresponding values used in http headers. Currently, APR can only use iconv(3), so you can easily test your character set names using the iconv(1) program, as follows:

iconv -f charsetsourceenc-value -t charsetdefault-value

Mismatch between character set of content and translation rules

If the translation rules don't make sense for the content, translation can fail in various ways, including:

  • The translation mechanism may return a bad return code, and the connection will be aborted.
  • The translation mechanism may silently place special characters (e.g., question marks) in the output buffer when it cannot translate the input buffer.
top

CharsetDefault Directive

Description:Charset to translate into
Syntax:CharsetDefault charset
Context:server config, virtual host, directory, .htaccess
Override:FileInfo
Status:Extension
Module:mod_charset_lite

The CharsetDefault directive specifies the charset that content in the associated container should be translated to.

The value of the charset argument must be accepted as a valid character set name by the character set support in APR. Generally, this means that it must be supported by iconv.

Example

<Directory /export/home/trawick/apacheinst/htdocs/convert>
CharsetSourceEnc UTF-16BE
CharsetDefault ISO-8859-1
</Directory>

top

CharsetOptions Directive

Description:Configures charset translation behavior
Syntax:CharsetOptions option [option] ...
Default:CharsetOptions DebugLevel=0 NoImplicitAdd
Context:server config, virtual host, directory, .htaccess
Override:FileInfo
Status:Extension
Module:mod_charset_lite

The CharsetOptions directive configures certain behaviors of mod_charset_lite. Option can be one of

DebugLevel=n
The DebugLevel keyword allows you to specify the level of debug messages generated by mod_charset_lite. By default, no messages are generated. This is equivalent to DebugLevel=0. With higher numbers, more debug messages are generated, and server performance will be degraded. The actual meanings of the numeric values are described with the definitions of the DBGLVL_ constants near the beginning of mod_charset_lite.c.
ImplicitAdd | NoImplicitAdd
The ImplicitAdd keyword specifies that mod_charset_lite should implicitly insert its filter when the configuration specifies that the character set of content should be translated. If the filter chain is explicitly configured using the AddOutputFilter directive, NoImplicitAdd should be specified so that mod_charset_lite doesn't add its filter.
TranslateAllMimeTypes | NoTranslateAllMimeTypes
Normally, mod_charset_lite will only perform translation on a small subset of possible mimetypes. When the TranslateAllMimeTypes keyword is specified for a given configuration section, translation is performed without regard for mimetype.
top

CharsetSourceEnc Directive

Description:Source charset of files
Syntax:CharsetSourceEnc charset
Context:server config, virtual host, directory, .htaccess
Override:FileInfo
Status:Extension
Module:mod_charset_lite

The CharsetSourceEnc directive specifies the source charset of files in the associated container.

The value of the charset argument must be accepted as a valid character set name by the character set support in APR. Generally, this means that it must be supported by iconv.

Example

<Directory /export/home/trawick/apacheinst/htdocs/convert>
CharsetSourceEnc UTF-16BE
CharsetDefault ISO-8859-1
</Directory>

The character set names in this example work with the iconv translation support in Solaris 8.

mod/mod_dav.html100644 0 0 43036 11237400230 11301 0ustar 0 0 mod_dav - Apache HTTP サーバ
<-

Apache モジュール mod_dav

This translation may be out of date. Check the English version for recent changes.
説明:分散オーサリングとバージョン管理 (WebDAV) 機能
ステータス:Extension
モジュール識別子:dav_module
ソースファイル:mod_dav.c

概要

このモジュールはクラス 1 とクラス 2 の WebDAV ('ウェブベースの分散オーサリングとバージョン管理') 機能を Apache に提供します。 この HTTP プロトコルの拡張により、リモートのウェブサーバ上にある リソースやコレクションを 作成、移動、複製、削除できるようになります。

top

Enabling WebDAV

mod_dav を有効にするには、httpd.conf ファイル中のコンテナに次を加えます:

Dav On

これは DAV ファイルシステムプロバイダを有効にします。DAV ファイルシステムプロバイダは mod_dav_fs モジュールで実装されています。ですから、このモジュールはコンパイル時に サーバに組み込まれているか、あるいは LoadModule を使用して実行時にロードされている必要があります。

さらに、DAV ロックデータベースの場所が DavLockDB ディレクティブを使って httd.conf ファイルのグローバルセクションに指定されている 必要があります。

DavLockDB /usr/local/apache2/var/DavLock

ロックデータベースファイルのあるディレクトリは Apache が実行されている UserGroup に書き込み権限がある必要があります。

<Limit> 節を <Location> ディレクティブ内部に追加して、DAV が有効な場所への アクセスを制限することもできます。DAV クライアントが 一度のリクエストで送信できる最大バイト数を指定したいときは、 LimitXMLRequestBody ディレクティブを使用する必要があります。「通常の」 LimitRequestBody ディレクティブは DAV リクエストに対しては効力を持ちません。

完全な例

DavLockDB /usr/local/apache2/var/DavLock

<Location /foo>
Order Allow,Deny
Allow from all
Dav On

AuthType Basic
AuthName DAV
AuthUserFile user.passwd

<LimitExcept GET OPTIONS>
require user admin
</LimitExcept>
</Location>

mod_dav は Greg Stein さんの Apache 1.3 用の mod_dav に 由来するものです。そのサイトからより多くの情報を手に入れることができます。

top

セキュリティの問題

DAV のアクセスメソッドは遠隔クライアントがサーバのファイルを 操作することを可能にしますので、 mod_dav を使用する 前に、サーバが安全であることを特に注意して確認しなければなりません。

サーバ上の DAV が使用可能になっている場所はすべて認証で保護してください。 HTTP 基本認証の使用は推奨できません。少なくとも mod_auth_digest モジュールで提供される HTTP ダイジェスト認証を用いるべきです。WebDAV クライアントのほとんどは この認証方法に対応しています。代わりに、SSL が 有効なコネクションを通した基本認証を使うこともできます。

mod_dav がファイルを操作できるようにするためには、 管理下のディレクトリとファイルとに Apache が実行されている UserGroup で書き込み可能である必要があります。 新しく作成されるファイルもこの UserGroup に所有される ことになります。この理由から、そのアカウントへのアクセスを制御することは 重要です。DAV リポジトリは Apache 専用のものだとみなされています。 Apache 以外の方法でファイルを修正すること (例えば FTP やファイルシステム 用のツールなどを使って) は許可されていません。

mod_dav はいろいろな種類のサービス拒否攻撃にさらされる かもしれません。LimitXMLRequestBody ディレクティブを使うと 大きな DAV リクエストを解析するときに消費されるメモリの量を制限することが できます。DavDepthInfinity ディレクティブは PROPFIND リクエストが巨大リポジトリで大量のメモリを消費するのを 防ぐことができます。他のサービス拒否攻撃には単純に使用可能なディスク領域を 多くの大きなファイルで埋めてしまうんものがあります。これを直接防ぐ方法は Apache にはありませんので、信用できないユーザに DAV アクセスを提供するのは 避けた方が良いでしょう。

top

複雑な設定

よくある要求に、mod_dav を使って動的なファイル (PHP スクリプト、CGI スクリプトなど) を操作したいというものがあります。 これの実現は、GET リクエストはスクリプトの内容をダウンロードさせる 代わりに、スクリプトを常に実行させてしまうので難しくなっています。 これを回避する方法には、二つの違う URL を同じコンテンツにマップし、 一つはスクリプトを実行させ、もう一つはダウンロードさせたり、DAV から 操作されたりするように設定するというものがあります。

Alias /phparea /home/gstein/php_files
Alias /php-source /home/gstein/php_files
<Location /php-source> DAV On
ForceType text/plain
</Location>

この設定により、http://example.com/phparea を PHP スクリプトの 出力をアクセスするために使うことができ、 http://example.com/php-source を DAV クライアントによる が操作のために使うことができます。

top

Dav ディレクティブ

説明:WebDAV HTTP メソッドを有効にします
構文:Dav On|Off|provider-name
デフォルト:Dav Off
コンテキスト:ディレクトリ
ステータス:Extension
モジュール:mod_dav

与えられたコンテナで WebDAV HTTP メソッドが使えるようにするには 次のようにします。

<Location /foo>
Dav On
</Location>

On という指定は実際には mod_dav_fs で提供されているデフォルトのプロバイダ、filesystem へのエイリアスになっています。一度あるロケーションで DAV を有効にした後は、そのサブロケーションで無効化することはできない ということに注意してください。完全な設定例は上記のセクション をご覧下さい。

サーバのセキュリティが確保できるまで WebDAV を有効にしないでください。 そうしなければ誰でもそのサーバでファイルを配布することができるように なってしまいます。
top

DavDepthInfinity ディレクティブ

説明:PROPFIND, Depth: Infinity リクエストを許可します
構文:DavDepthInfinity on|off
デフォルト:DavDepthInfinity off
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ
ステータス:Extension
モジュール:mod_dav

'Depth: Infinity' を含んでいる PROPFIND リクエストを処理できるようにするには、 DavDepthInfinity ディレクティブを使います。このタイプのリクエストは denial-of-service アタックとなりうるので、 デフォルトでは許可されていません。

top

DavMinTimeout ディレクティブ

説明:サーバが DAV リソースのロックを維持する最小時間です。
構文:DavMinTimeout seconds
デフォルト:DavMinTimeout 0
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ
ステータス:Extension
モジュール:mod_dav

クライアントが DAV リソースロックを要求した場合、 ロックがサーバによって自動的に解除されるまでの時間を 同時に指定することができます。この値は単なるリクエストであって、 サーバはこれを無視することもできますし、 任意の値をクライアントに通知することもできます。

クライアントに戻すロックタイムアウトの最小時間を、 秒で、指定するために DavMinTimeout ディレクティブを使います。 マイクロソフトのウェブフォルダのデフォルトでは 120 秒ですが; ネットワークの遅延のせいでクライアントがロックを失うのを減らすために、 DavMinTimeout を使って これをもっと大きな値 (例えば 600 秒) に上書きできます。

<Location /MSWord>
DavMinTimeout 600
</Location>

mod/mod_dav_fs.html100644 0 0 12353 11237400230 11767 0ustar 0 0 mod_dav_fs - Apache HTTP サーバ
<-

Apache モジュール mod_dav_fs

説明:mod_dav のためのファイルシステムプロバイダ
ステータス:Extension
モジュール識別子:dav_fs_module
ソースファイル:mod_dav_fs.c

概要

このモジュールは mod_dav のサービスを必要としますmod_dav のサポートモジュールとして動作し、サーバファイルシステム上に 位置するリソースへのアクセスを提供します。このプロバイダの正式な名前は filesystem です。mod_dav バックエンドプロバイダは Dav ディレクティブを使用して起動されます。

Dav filesystem

filesystemmod_dav のデフォルトプロバイダになっていますから、代わりに単に On と指定することもできます。

ディレクティブ

参照

top

DavLockDB ディレクティブ

説明:DAV ロックデータベースの位置
構文:DavLockDB file-path
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_dav_fs

ロックデータベースへのフルパスを、拡張子を除いた形で 指定するには、DavLockDB を使います。パスが絶対パスでなければ、ServerRoot からの相対パスと解釈されます。 mod_dav_fs 実装では、ユーザロックを 追跡するために SDBM データベースを使います。

DavLockDB logs/DavLock

mod/mod_dav_lock.html100644 0 0 15765 11237400230 12321 0ustar 0 0 mod_dav_lock - Apache HTTP サーバ
<-

Apache モジュール mod_dav_lock

This translation may be out of date. Check the English version for recent changes.
説明:mod_dav 用の汎用ロックモジュール
ステータス:Extension
モジュール識別子:dav_lock_module
ソースファイル:mod_dav_lock.c
互換性:バージョン 2.1 以降

概要

このモジュールは mod_dav のどのバックエンド からでも使える汎用ロック API を提供します。 使用には最低限 mod_dav を必要としますが、これを利用するバックエンドが存在しないと役に立たないので、 そのような場合はサーバに読み込むべきではありません。 mod_dav_lock を実際に利用するバックエンドモジュールの例としては subversion プロバイダモジュールの mod_dav_svn があります。

mod_dav_fs は特化された専用のバージョンを 使うため、この汎用モジュールは必要ないことに注意して ください。

mod_dav_lock を機能させるには、 以下で説明されている DavGenericLockDB を使って ロックデータベースの場所を指定するだけです。

開発者向けのメモ

ロックを提供している関数へのポインタを取得するためには、 ap_lookup_provider API を、引数 dav-lock, generic, 0 を指定して使う必要が あります。

ディレクティブ

参照

top

DavGenericLockDB ディレクティブ

説明:DAV ロックデータベースの場所
構文:DavGenericLockDB file-path
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ
ステータス:Extension
モジュール:mod_dav_lock

DavGenericLockDB ディレクティブを 使って、拡張子を除いたロックデータベースへのフルパスを 指定します。絶対パスでないときは ServerRoot からの相対パスとして 扱われます。mod_dav_lock の実装ではユーザの ロックを追跡するのに SDBM データベースを使います。

DavGenericLockDB var/DavLock

ロックデータベースファイルのあるディレクトリは Apache が実行されている UserGroup によって 書き込み可能でなければなりません。セキュリティ上の理由から、 既存のディレクトリのパーミッションを変更するのではなく、 専用のディレクトリを作るのが良いでしょう。上の例では、 Apache は ServerRoot の下の var/ ディレクトリに、ファイル名の本体が DavLock で サーバが選択した拡張子を持つファイルを作成します。

mod/mod_dbd.html100644 0 0 40637 11237400230 11264 0ustar 0 0 mod_dbd - Apache HTTP Server
<-

Apache Module mod_dbd

Description:Manages SQL database connections
Status:Extension
ModuleIdentifier:dbd_module
SourceFile:mod_dbd.c
Compatibility:Version 2.1 and later

Summary

mod_dbd manages SQL database connections using APR. It provides database connections on request to modules requiring SQL database functions, and takes care of managing databases with optimal efficiency and scalability for both threaded and non-threaded MPMs. For details, see the APR website and this overview of the Apache DBD Framework by its original developer.

top

Connection Pooling

This module manages database connections, in a manner optimised for the platform. On non-threaded platforms, it provides a persistent connection in the manner of classic LAMP (Linux, Apache, Mysql, Perl/PHP/Python). On threaded platform, it provides an altogether more scalable and efficient connection pool, as described in this article at ApacheTutor. Note that mod_dbd supersedes the modules presented in that article.

top

Apache DBD API

mod_dbd exports five functions for other modules to use. The API is as follows:

typedef struct {
    apr_dbd_t *handle;
    apr_dbd_driver_t *driver;
    apr_hash_t *prepared;
} ap_dbd_t;

/* Export functions to access the database */

/* acquire a connection that MUST be explicitly closed.
 * Returns NULL on error
 */
AP_DECLARE(ap_dbd_t*) ap_dbd_open(apr_pool_t*, server_rec*);

/* release a connection acquired with ap_dbd_open */
AP_DECLARE(void) ap_dbd_close(server_rec*, ap_dbd_t*);

/* acquire a connection that will have the lifetime of a request
 * and MUST NOT be explicitly closed.  Return NULL on error.
 * This is the preferred function for most applications.
 */
AP_DECLARE(ap_dbd_t*) ap_dbd_acquire(request_rec*);

/* acquire a connection that will have the lifetime of a connection
 * and MUST NOT be explicitly closed.  Return NULL on error.
 */
AP_DECLARE(ap_dbd_t*) ap_dbd_cacquire(request_rec*);

/* Prepare a statement for use by a client module */
AP_DECLARE(void) ap_dbd_prepare(server_rec*, const char*, const char*);

/* Also export them as optional functions for modules that prefer it */
APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_open, (apr_pool_t*, server_rec*));
APR_DECLARE_OPTIONAL_FN(void, ap_dbd_close, (server_rec*, ap_dbd_t*));
APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_acquire, (request_rec*));
APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_cacquire, (conn_rec*));
APR_DECLARE_OPTIONAL_FN(void, ap_dbd_prepare, (server_rec*, const char*, const char*));
top

SQL Prepared Statements

mod_dbd supports SQL prepared statements on behalf of modules that may wish to use them. Each prepared statement must be assigned a name (label), and they are stored in a hash: the prepared field of an ap_dbd_t. Hash entries are of type apr_dbd_prepared_t and can be used in any of the apr_dbd prepared statement SQL query or select commands.

It is up to dbd user modules to use the prepared statements and document what statements can be specified in httpd.conf, or to provide their own directives and use ap_dbd_prepare.

top

DBDExptime Directive

Description:Keepalive time for idle connections
Syntax:DBDExptime time-in-seconds
Default:DBDExptime 300
Context:server config, virtual host
Status:Extension
Module:mod_dbd

Set the time to keep idle connections alive when the number of connections specified in DBDKeep has been exceeded (threaded platforms only).

top

DBDKeep Directive

Description:Maximum sustained number of connections
Syntax:DBDKeep number
Default:DBDKeep 2
Context:server config, virtual host
Status:Extension
Module:mod_dbd

Set the maximum number of connections per process to be sustained, other than for handling peak demand (threaded platforms only).

top

DBDMax Directive

Description:Maximum number of connections
Syntax:DBDMax number
Default:DBDMax 10
Context:server config, virtual host
Status:Extension
Module:mod_dbd

Set the hard maximum number of connections per process (threaded platforms only).

top

DBDMin Directive

Description:Minimum number of connections
Syntax:DBDMin number
Default:DBDMin 1
Context:server config, virtual host
Status:Extension
Module:mod_dbd

Set the minimum number of connections per process (threaded platforms only).

top

DBDParams Directive

Description:Parameters for database connection
Syntax:DBDParams param1=value1[,param2=value2]
Context:server config, virtual host
Status:Extension
Module:mod_dbd

As required by the underlying driver. Typically this will be used to pass whatever cannot be defaulted amongst username, password, database name, hostname and port number for connection.

Connection string parameters for current drivers include:

MySQL
host, port, user, pass, dbname, sock
Oracle
user, pass, dbname, server
PostgreSQL
The connection string is passed straight through to PQconnectdb
SQLite2
The connection string is split on a colon, and part1:part2 is used as sqlite_open(part1, atoi(part2), NULL)
SQLite3
The connection string is passed straight through to sqlite3_open
top

DBDPersist Directive

Description:Whether to use persistent connections
Syntax:DBDPersist On|Off
Context:server config, virtual host
Status:Extension
Module:mod_dbd

If set to Off, persistent and pooled connections are disabled. A new database connection is opened when requested by a client, and closed immediately on release. This option is for debugging and low-usage servers.

The default is to enable a pool of persistent connections (or a single LAMP-style persistent connection in the case of a non-threaded server), and should almost always be used in operation.

Prior to version 2.2.2, this directive accepted only the values 0 and 1 instead of Off and On, respectively.

top

DBDPrepareSQL Directive

Description:Define an SQL prepared statement
Syntax:DBDPrepareSQL "SQL statement" label
Context:server config, virtual host
Status:Extension
Module:mod_dbd

For modules such as authentication that repeatedly use a single SQL statement, optimum performance is achieved by preparing the statement at startup rather than every time it is used. This directive prepares an SQL statement and assigns it a label.

top

DBDriver Directive

Description:Specify an SQL driver
Syntax:DBDriver name
Context:server config, virtual host
Status:Extension
Module:mod_dbd

Selects an apr_dbd driver by name. The driver must be installed on your system (on most systems, it will be a shared object or dll). For example, DBDriver mysql will select the MySQL driver in apr_dbd_mysql.so.

mod/mod_deflate.html100644 0 0 55163 11237400230 12137 0ustar 0 0 mod_deflate - Apache HTTP サーバ
<-

Apache モジュール mod_deflate

説明:クライアントへ送られる前にコンテンツを圧縮する
ステータス:Extension
モジュール識別子:deflate_module
ソースファイル:mod_deflate.c

概要

mod_deflate モジュールは DEFLATE 出力フィルタを提供します。これはサーバからの出力を、ネットワークを 通してクライアントに送る前に圧縮することを可能にします。

top

サンプル設定

下にせっかちな人向けの簡単な設定例を示します。

数タイプのみ圧縮する

AddOutputFilterByType DEFLATE text/html text/plain text/xml

以下の設定はコンテンツをより圧縮しますが、ずっと複雑な設定になります。 設定の隅々までよく理解しないで使わないでください。

画像以外全て圧縮する

<Location />
# Insert filter
SetOutputFilter DEFLATE

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>

top

圧縮を有効にする

Output Compression

圧縮機能は DEFLATE フィルタ により実装されています。以下のディレクティブはそのディレクティブのある コンテナ中のドキュメントを圧縮するようにします:

SetOutputFilter DEFLATE

よく使われているブラウザでは、すべてのコンテンツに対する 圧縮を扱えるわけではありません。ですから、gzip-only-text/html ノートを 1 にして、html ファイルに対してのみ 圧縮が働くようにした方がよいかもしれません (以下参照) この値を 1 以外の値に設定した場合は無視されます。

通常、特定のMIMEタイプについてのみ圧縮したいのであれば、 AddOutputFilterByType ディレクティブを使用します。次に Apache のドキュメントの html ファイルのみの圧縮を有効にする例を示します。

<Directory "/your-server-root/manual">
AddOutputFilterByType DEFLATE text/html
</Directory>

全てのファイルタイプでの圧縮に問題を抱えているブラウザに対しては、 BrowserMatch ディレクティブを使用して、特定のブラウザに no-gzip ノートをセットし、圧縮が行なわれないようにします。 no-gzipgzip-only-text/html を組み合わせることで上手く対処できます。 この場合、前者が後者をオーバーライドします。 上記の設定例の抜粋を 次に示しますのでご覧下さい。

BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

まず始めに User-Agent 文字列から Netscape Navigator 4.x であるかどうかを調べます。これらのバージョンでは、 text/html 以外のタイプの圧縮を扱うことができません。 4.06, 4.07, 4.08 は html ファイルの伸張にも問題を抱えています。 ですからこれらに対しては、完全に deflate フィルタをオフにします。

3 番目の BrowserMatch ディレクティブで、推測したユーザーエージェントを修正します。 なぜなら Microsoft Internet Explorer も "Mozilla/4" と特定されますが、 これらは実際には圧縮を扱うことができるからです。 User-Agent ヘッダを "MSIE" (\b は「単語の境界」を意味します) の追加文字で検査して、 これ以前に設定した制限を再び解除します。

DEFLATE フィルタは必ず、PHP や SSI といった RESOURCE フィルタの後になります。 DEFLATE フィルタは内部的なサブリクエストを関知しません。

SetEnv で設定される force-gzip 環境変数がありますが、これは ブラウザの accept-encoding 設定を無視し、圧縮した出力をします。

出力の伸長

mod_deflate モジュールは、gzip 圧縮されたレスポンス 本文を inflate/uncompress するフィルタも提供しています。 この機能を有効にするには、SetOutputFilterAddOutputFilter を使って、 INFLATE フィルタを出力フィルタチェインに挿入します。 例えば次のようにします。

<Location /dav-area>
ProxyPass http://example.com/
SetOutputFilter INFLATE
</Location>

この例では、example.com からの gzip 圧縮された出力を伸長し、 その他のフィルタがさらにその出力を処理できるようにします。

入力の伸張

mod_deflate モジュールは、gzip で圧縮されたリクエスト本体を伸張するフィルタも提供しています。 この機能を有効にするには、SetInputFilterAddInputFilter を使用して、 DEFLATE フィルタを入力フィルタチェインに組み込みます。 例えば次のようになります。

<Location /dav-area>
SetInputFilter DEFLATE
</Location>

この設定であれば、Content-Encoding: gzip ヘッダを含むリクエストが来ると、本体は自動的に伸張されます。 gzip リクエスト本体を送信するブラウザはあまりありません。 しかし、例えば WebDAV クライアントの幾つかなど、特別なアプリケーションでリクエストの 圧縮を実際にサポートしているものもあります。

Content-Length に関する注意

リクエスト本体それ自体を評価する場合は、Content-Length ヘッダを信用しないでください。Content-Length ヘッダは、 クライアントから送信されるデータの長さを反映しているのであって、 伸張されたデータストリームのバイトカウントではありません

top

Proxy サーバでの扱い

mod_deflate モジュールは Vary: Accept-Encoding HTTP 応答ヘッダを送信して、適切な Accept-Encoding リクエストヘッダを送信するクライアントに対してのみ、 プロクシサーバがキャッシュした応答を送信するように注意を喚起します。 このようにして、圧縮を扱うことのできないクライアントに 圧縮された内容が送られることのないようにします。

もし特別に何かに依存して除外したい場合、例えば User-Agent ヘッダなどに依存している場合、手動で Vary ヘッダを設定して、 追加の制限についてプロクシサーバに注意を行なう必要があります。 例えば User-Agent に依存して DEFLATE を追加する典型的な設定では、次のように追加することになります。

Header append Vary User-Agent

リクエストヘッダ以外の情報 (例えば HTTP バージョン) に依存して圧縮するかどうか決める場合、 Vary ヘッダを * に設定する必要があります。 このようにすると、仕様に準拠したプロクシはキャッシュを全く行なわなくなります。

Header set Vary *

top

DeflateBufferSize ディレクティブ

説明:zlib が一度に圧縮する塊の大きさ
構文:DeflateBufferSize value
デフォルト:DeflateBufferSize 8096
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_deflate

DeflateBufferSize ディレクティブは zlib が一度に圧縮する塊の大きさをバイト単位で指定します。

top

DeflateCompressionLevel ディレクティブ

説明:出力に対して行なう圧縮の程度
構文:DeflateCompressionLevel value
デフォルト:Zlib のデフォルト
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_deflate
互換性:This directive is available since Apache 2.0.45

DeflateCompressionLevel ディレクティブは 圧縮の程度を設定します。大きな値では、より圧縮が行なわれますが、 CPU 資源を消費します。

値は 1 (低圧縮) から 9 (高圧縮) です。

top

DeflateFilterNote ディレクティブ

説明:ロギング用に圧縮比をメモに追加
構文:DeflateFilterNote [type] notename
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_deflate
互換性:type is available since Apache 2.0.45

DeflateFilterNote ディレクティブは 圧縮比に関するメモがリクエストに付加されることを指定します。 メモ (note) の名前はディレクティブに指定された値です。 メモはアクセスログに 値を記録し、統計を取る目的にも使えます。

DeflateFilterNote ratio

LogFormat '"%r" %b (%{ratio}n) "%{User-agent}i"' deflate
CustomLog logs/deflate_log deflate

ログからもっと精密な値を抽出したい場合は、type 引数を使用して、データタイプをログのメモとして残すように指定できます。 type は次のうちの一つです。

Input
フィルタの入力ストリームのバイトカウントをメモに保存する。
Output
フィルタの出力ストリームのバイトカウントをメモに保存する。
Ratio
圧縮率 (出力 / 入力 * 100) をメモに保存する。 type 引数を省略した場合は、これがデフォルトとなります。

まとめると、次のようにログを取ることになるでしょう。

精密なログ採取

DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio

LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog logs/deflate_log deflate

参照

top

DeflateMemLevel ディレクティブ

説明:zlib が圧縮に使うメモリのレベルを指定
構文:DeflateMemLevel value
デフォルト:DeflateMemLevel 9
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_deflate

DeflateMemLevel ディレクティブは zlib が圧縮に使うメモリのレベルを設定します (1 から 9 の間の値)。 (訳注: 2 を底とする対数の値になります。 8 程度が良いでしょう。)

top

DeflateWindowSize ディレクティブ

説明:Zlib の圧縮用ウィンドウの大きさ
構文:DeflateWindowSize value
デフォルト:DeflateWindowSize 15
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_deflate

DeflateWindowSize ディレクティブは zlib の圧縮用ウィンドウ (訳注: zlib で使用される履歴バッファ) の大きさを指定します (1 から 15 の間の値)。 一般的に大きなウィンドウサイズを使用すると圧縮率が向上します。 (訳注: 2 を底とする対数の値になります。 8 から 15 にするのが良いでしょう。)

mod/mod_dir.html100644 0 0 26347 11237400230 11313 0ustar 0 0 mod_dir - Apache HTTP サーバ
<-

Apache モジュール mod_dir

説明:「最後のスラッシュ」のリダイレクトと、ディレクトリの インデックスファイルを扱う機能を提供する
ステータス:Base
モジュール識別子:dir_module
ソースファイル:mod_dir.c

概要

ディレクトリインデックスは、次の二つのうちどちらかが利用されます:

  • 一つ目は、ユーザが作成したファイルを用いるもので、通常 index.html というファイル名を使います。このファイル名は、 DirectoryIndex ディレクティブで 指定することができます。この機能は mod_dir モジュールで提供されます。
  • もう一つの方法は、 サーバによって自動的に生成されるディレクトリリストを用いる場合です。 この機能は、mod_autoindex モジュールにより提供されます。

自動的なインデックス生成機能を削除 (もしくは交換) できるように、この二つの機能は分離されています。

なお http://servername/foo/dirname という URL へのリクエストがあった際に、dirname というディレクトリがあれば、「最後にスラッシュをつけた形」の URL へのリダイレクトを送出します。 ディレクトリへのアクセスはスラッシュで終わっている必要があり、 mod_dir は、http://servername/foo/dirname/ へのリダイレクトを送出することになります。

ディレクティブ

top

DirectoryIndex ディレクティブ

説明:クライアントがディレクトリをリクエストしたときに調べる リソースのリスト
構文:DirectoryIndex local-url [local-url] ...
デフォルト:DirectoryIndex index.html
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_dir

クライアントが、ディレクトリ名の最後に「/」 を指定してディレクトリインデックスを要求する場合に探すリソースのリストを DirectoryIndex ディレクティブで設定します。 Local-url は、リクエストされたディレクトリに対応する、サーバ上のドキュメントの (% エンコードされた) URL で、普通はディレクトリ中のファイルの名前です。 複数の URL が設定された場合には、最初に見つかったものを返します。 それらが見つからず、Indexes オプションがセットされている場合、ディレクトリのリストを生成します。

DirectoryIndex index.html

http://myserver/docs/ へのアクセスがあり、 http://myserver/docs/index.html が存在すれば、この URL が返されます。 もし存在しなければ、ディレクトリのリストが返されます。

注: ドキュメントが同じディレクトリ内に存在するは必要ありません。

DirectoryIndex index.html index.txt /cgi-bin/index.pl

とした場合、index.htmlindex.txt のどちらもディレクトリ内に存在しない場合、CGI スクリプト /cgi-bin/index.pl が実行されます。

top

DirectorySlash ディレクティブ

説明:パス末尾のスラッシュでリダイレクトするかどうかのオンオフをトグルさせる
構文:DirectorySlash On|Off
デフォルト:DirectorySlash On
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Base
モジュール:mod_dir
互換性:2.0.51 以降

要求のあった URL がディレクトリを指すかどうかを、 mod_dir が調整するべきかどうかを DirectorySlash ディレクティブで設定します。

典型的には、ユーザが末尾のスラッシュ無しでリソースへのリクエストを発行し、 そして、そのリソースがディレクトリを指していた場合、mod_dir は、末尾にスラッシュを付加した上で同じリソースにリダイレクトさせます。 この挙動には幾つか理由があります:

  • ユーザは、最終的にはリソースの別名 URL をリクエストすることになる。
  • mod_autoindex が期待通りに動く。mod_autoindex の生成するリンクはパスを出力しませんので、スラッシュがない場合は間違ったパスを 指してしまうことになります。
  • DirectoryIndex は、 末尾にスラッシュがついているリクエストについてのみ評価される。
  • HTML ページの相対 URL 参照が正しく動作する。

とはいえ、もしこういった効果を望まない、かつ、 上記のような理由が当てはまらない場合は、リダイレクトを次のようにしてオフにできます:

# see security warning below!
<Location /some/path>
DirectorySlash Off
SetHandler some-handler
</Location>

セキュリティ警告

末尾のスラッシュでのリダイレクトをオフにすると、結果的に情報漏洩を 招くことになるかもしれません。 mod_autoindex が有効 (Options +Indexes) で、 DirectoryIndex が有効なリソース (例えば index.html) を指していて、また、要求のあった URL に特別な ハンドラが設定されていない場合を考えてみてください。 この場合末尾にスラッシュのついているリクエストに対しては index.html ファイルが返されます。しかしスラッシュのないリクエストに対しては、 ディレクトリの内容一覧を返してしまいます。

mod/mod_disk_cache.html100644 0 0 27275 11237400230 12613 0ustar 0 0 mod_disk_cache - Apache HTTP サーバ
<-

Apache モジュール mod_disk_cache

This translation may be out of date. Check the English version for recent changes.
説明:URI をキーにしたコンテンツキャッシュストレージ管理
ステータス:Extension
モジュール識別子:disk_cache_module
ソースファイル:mod_disk_cache.c

概要

mod_disk_cache はディスクを使用したストレージ 管理機構を実装しています。主に mod_cache と組み合わせて使われます。

コンテンツのキャッシュへの保存と取得は URI に基づいたキーが使われます。 アクセス保護のかけられているコンテンツはキャッシュされません。

キャッシュの大きさを最大レベルで維持するために htcacheclean を使うことができます。

注:

mod_disk_cachemod_cache を必要とします

top

CacheDirLength ディレクティブ

説明:サブディレクトリ名の文字数
構文:CacheDirLength length
デフォルト:CacheDirLength 2
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_disk_cache

CacheDirLength ディレクティブはキャッシュ 階層の各サブディレクトリの文字数を設定します。

CacheDirLevels* CacheDirLength の 結果は 20 以内でなければなりません。

CacheDirLength 4

top

CacheDirLevels ディレクティブ

説明:キャッシュのサブディレクトリの深さの数
構文:CacheDirLevels levels
デフォルト:CacheDirLevels 3
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_disk_cache

CacheDirLevels ディレクティブはキャッシュの サブディレクトリの深さを設定します。キャッシュデータは CacheRoot ディレクトリから このディレクトリの深さ分下のディレクトリに保存されます。

CacheDirLevels* CacheDirLength の 結果は 20 以内でなければなりません。

CacheDirLevels 5

top

CacheMaxFileSize ディレクティブ

説明:キャッシュに保管されるドキュメントの最大の (バイトでの) サイズ
構文:CacheMaxFileSize bytes
デフォルト:CacheMaxFileSize 1000000
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_disk_cache

CacheMaxFileSize ディレクティブは、ドキュメントを キャッシュするかどうかを判定する、最大のサイズをバイト数で設定します。

CacheMaxFileSize 64000

top

CacheMinFileSize ディレクティブ

説明:キャッシュに保管されるドキュメントの最小限の (バイトでの) 大きさ
構文:CacheMinFileSize bytes
デフォルト:CacheMinFileSize 1
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_disk_cache

CacheMinFileSize ディレクティブは、ドキュメントを キャッシュするかどうかを判定する、最小のサイズをバイト数で設定します。

CacheMinFileSize 64

top

CacheRoot ディレクティブ

説明:キャッシュファイルが保管されるルートディレクトリ
構文:CacheRoot directory
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_disk_cache

CacheRoot ディレクティブはキャッシュファイルを 保管するためのディスク上のディレクトリを指定します。mod_disk_cache モジュールが Apache サーバにロードされて いるか、組み込まれていれば、このディレクティブは必ず 定義しなければなりません。 CacheRoot の値を指定しなければ、 設定ファイルの処理でエラーになります。CacheDirLevels ディレクティブと CacheDirLength ディレクティブが 指定されたルートディレクトリ下のディレクトリ構成を定義します。

CacheRoot c:/cacheroot

mod/mod_dumpio.html100644 0 0 15114 11237400230 12020 0ustar 0 0 mod_dumpio - Apache HTTP サーバ
<-

Apache モジュール mod_dumpio

This translation may be out of date. Check the English version for recent changes.
説明:望むようにすべての I/O をエラーログにダンプする
ステータス:Extension
モジュール識別子:dumpio_module
ソースファイル:mod_dumpio.c

概要

mod_dumpio を使うと、Apache が受け取ったすべての入力と Apache により送られたすべての出力との、両方もしくはどちらか一方を、 エラーログファイルにログ収集 (訳注: ダンプ dump) できます。

データのロギングは、SSL 復号化の直後 (入力) と SSL 暗号化の直前 (出力) に行なわれます。ご想像の通り、 このモジュールはとてつもないデータ量を出力しますので、 問題をデバッグしているときにのみ使用するようにしてください。

top

dumpio サポートを有効にする

このモジュールを有効にするには、モジュールがコンパイルされていて、 実行する Apache の設定でサーバに組み込まれている必要があります。 ロギング機能は、以下のディレクティブを使って有効にしたり 無効にしたりできます。

top

DumpIOInput ディレクティブ

説明:エラーログにすべての入力データをダンプ
構文:DumpIOInput On|Off
デフォルト:DumpIOInput Off
コンテキスト:サーバ設定ファイル
ステータス:Extension
モジュール:mod_dumpio
互換性:DumpIOInput は Apache 2.1.3 以降のみで使用可能

すべての入力のダンプを有効にします。

DumpIOInput On

top

DumpIOOutput ディレクティブ

説明:エラーログにすべての出力データをダンプ
構文:DumpIOOutput On|Off
デフォルト:DumpIOOutput Off
コンテキスト:サーバ設定ファイル
ステータス:Extension
モジュール:mod_dumpio
互換性:DumpIOOutput は Apache 2.1.3 以降でのみ使用可能

すべての出力のダンプを有効にします。

DumpIOOutput On

mod/mod_echo.html100644 0 0 10374 11237400230 11444 0ustar 0 0 mod_echo - Apache HTTP サーバ
<-

Apache モジュール mod_echo

This translation may be out of date. Check the English version for recent changes.
説明:プロトコルモジュールの概要を示すための単純なエコーサーバ
ステータス:Experimental
モジュール識別子:echo_module
ソースファイル:mod_echo.c
互換性:Apache 2.0 以降

概要

本モジュールはコンセプトを伝えるためのプロトコルモジュールの 実装例となっています。単純なエコーサーバを提供します。 Telnet で接続し、文字列を送信すると、エコーを返します。

ディレクティブ

top

ProtocolEcho ディレクティブ

説明:エコーサーバの有効無効を設定します。
構文:ProtocolEcho On|Off
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Experimental
モジュール:mod_echo
互換性:Apache 2.0 以降

ProtocolEcho ディレクティブで エコーサーバの有効無効を設定します。

ProtocolEcho On

mod/mod_env.html100644 0 0 15614 11237400230 11320 0ustar 0 0 mod_env - Apache HTTP サーバ
<-

Apache モジュール mod_env

説明:CGI スクリプト及び SSI ページに渡される環境変数を変更する機能を提供する
ステータス:Base
モジュール識別子:env_module
ソースファイル:mod_env.c

概要

このモジュールにより CGI スクリプトと SSI ページに適用される環境変数を制御することができるようになります。 環境変数は httpd プロセスを起動したシェルから渡されます。また、 設定ファイルで環境変数を設定したり、削除したりすることができます。

ディレクティブ

参照

top

PassEnv ディレクティブ

説明:シェルからの環境変数を渡す
構文:PassEnv env-variable [env-variable] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_env

httpd プロセスを起動したシェルの環境から CGI スクリプトと SSI ページに渡す環境変数を一つ以上指定します。

PassEnv LD_LIBRARY_PATH

top

SetEnv ディレクティブ

説明:環境変数を設定する
構文:SetEnv env-variable value
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_env

環境変数を設定し、それを CGI スクリプトと SSI ページに渡すようにします。

SetEnv SPECIAL_PATH /foo/bin

top

UnsetEnv ディレクティブ

説明:環境から変数を取り除く
構文:UnsetEnv env-variable [env-variable] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_env

CGI スクリプトと SSI ページに渡される環境変数から指定された環境変数を取り除きます。

UnsetEnv LD_LIBRARY_PATH

mod/mod_example.html100644 0 0 16735 11237400230 12170 0ustar 0 0 mod_example - Apache HTTP Server
<-

Apache Module mod_example

Description:Illustrates the Apache module API
Status:Experimental
ModuleIdentifier:example_module
SourceFile:mod_example.c

Summary

Some files in the modules/experimental directory under the Apache distribution directory tree are provided as an example to those that wish to write modules that use the Apache API.

The main file is mod_example.c, which illustrates all the different callback mechanisms and call syntaxes. By no means does an add-on module need to include routines for all of the callbacks - quite the contrary!

The example module is an actual working module. If you link it into your server, enable the "example-handler" handler for a location, and then browse to that location, you will see a display of some of the tracing the example module did as the various callbacks were made.

top

Compiling the example module

To include the example module in your server, follow the steps below:

  1. Run configure with --enable-example option.
  2. Make the server (run "make").

To add another module of your own:

  1. cp modules/experimental/mod_example.c modules/new_module/mod_myexample.c
  2. Modify the file.
  3. Create modules/new_module/config.m4.
    1. Add APACHE_MODPATH_INIT(new_module).
    2. Copy APACHE_MODULE line with "example" from modules/experimental/config.m4.
    3. Replace the first argument "example" with myexample.
    4. Replace the second argument with brief description of your module. It will be used in configure --help.
    5. If your module needs additional C compiler flags, linker flags or libraries, add them to CFLAGS, LDFLAGS and LIBS accordingly. See other config.m4 files in modules directory for examples.
    6. Add APACHE_MODPATH_FINISH.
  4. Create module/new_module/Makefile.in. If your module doesn't need special build instructions, all you need to have in that file is include $(top_srcdir)/build/special.mk.
  5. Run ./buildconf from the top-level directory.
  6. Build the server with --enable-myexample
top

Using the mod_example Module

To activate the example module, include a block similar to the following in your httpd.conf file:

<Location /example-info>
SetHandler example-handler
</Location>

As an alternative, you can put the following into a .htaccess file and then request the file "test.example" from that location:

AddHandler example-handler .example

After reloading/restarting your server, you should be able to browse to this location and see the brief display mentioned earlier.

top

Example Directive

Description:Demonstration directive to illustrate the Apache module API
Syntax:Example
Context:server config, virtual host, directory, .htaccess
Status:Experimental
Module:mod_example

The Example directive just sets a demonstration flag which the example module's content handler displays. It takes no arguments. If you browse to an URL to which the example content-handler applies, you will get a display of the routines within the module and how and in what order they were called to service the document request. The effect of this directive one can observe under the point "Example directive declared here: YES/NO".

mod/mod_expires.html100644 0 0 34342 11237400230 12206 0ustar 0 0 mod_expires - Apache HTTP サーバ
<-

Apache モジュール mod_expires

説明:ユーザの指定した基準に基づいた ExpiresCache-Control HTTP ヘッダの生成
ステータス:Extension
モジュール識別子:expires_module
ソースファイル:mod_expires.c

概要

このモジュールはサーバ応答の Expires HTTP ヘッダ と Cache-Control ヘッダの max-age ディレクティブの 設定を制御します。元のファイルが作成された時刻または クライアントのアクセス時刻のどちらかに基づいて期限切れ日を 設定することができます。

これらのヘッダはクライアントに文書の 有効性と継続性を指示します。文書がキャッシュされた場合には、 指定時刻に達するまでは、元の場所から取得する代わりに キャッシュされているものを使うことができます。その後は、 キャッシュにあるコピーは期限切れ (expired) で無効であるとされ、 元の場所から新しいものを取得する必要があります。

max-age 以外 (RFC 2616 section 14.9 参照) の Cache-Control のディレクティブを 操作するには Header ディレクティブを 使うことができます。

top

代替期間指定構文

ExpiresDefault ディレクティブと ExpiresByType ディレクティブは 以下のより読み易い構文を使って定義することができます:

ExpiresDefault "<base> [plus] {<num> <type>}*"
ExpiresByType type/encoding "<base> [plus] {<num> <type>}*"

<base> は以下のどれかです:

  • access
  • now ('access' と等価)
  • modification

plus キーワードは省略可能です。<num> は (atoi() が受け付ける) 整数値、 <type> は以下のどれかです:

  • years
  • months
  • weeks
  • days
  • hours
  • minutes
  • seconds

例えば、以下のディレクティブはどれもデフォルトで文書がアクセスの 1 ヶ月後に 期限が切れるようにするために使えます:

ExpiresDefault "access plus 1 month"
ExpiresDefault "access plus 4 weeks"
ExpiresDefault "access plus 30 days"

期限切れ時刻はいくつか '<num> <type>' 節を追加することでより細かく 制御することができます:

ExpiresByType text/html "access plus 1 month 15 days 2 hours"
ExpiresByType image/gif "modification plus 5 hours 3 minutes"

修正時刻に基づいた設定を使用している場合、Expires ヘッダは ディスクのファイル以外のコンテンツには追加されないことに注意 してください。そのようなコンテンツには修正時刻は存在しないからです。

top

ExpiresActive ディレクティブ

説明:Expires ヘッダの生成を有効にする
構文:ExpiresActive On|Off
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Extension
モジュール:mod_expires

このディレクティブは対応するドキュメントの領域で ExpiresCache-Controlヘッダを 有効にするか無効にするかを決めます。 (例えば、.htaccess ファイルではそのディレクトリの 文書のみに適用されるということです。) Off に 設定された場合は対応領域でそれらのヘッダは 生成されません (.htaccess がサーバ設定ファイルの設定を 上書きする、というような下位レベルでの上書きがされていなければ)。 On に設定されていれば、ヘッダは ExpiresByType ディレクティブと ExpiresDefault ディレクティブ の基準に従って文書にヘッダを追加します (各ディレクティブ参照)。

このディレクティブは ExpiresCache-Control ヘッダの存在を 保証するわけではないことに注意してください。基準が満たされて いない場合はヘッダは追加されず、結果としてこのディレクティブが 指定されていなかったかのようにさえ見えることになります。

top

ExpiresByType ディレクティブ

説明:MIME タイプによって設定される Expires ヘッダの値
構文:ExpiresByType MIME-type <code>seconds
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Extension
モジュール:mod_expires

このディレクティブは指定されたタイプのドキュメント (例えば text/html) に対して生成される Expires ヘッダと Cache-Control ヘッダの max-age ディレクティブの値を定義します。 二つ目の引数は期限切れの日時を生成するための基準時刻に追加される 秒数を設定します。Cache-Control: max-age は期限切れの時刻からリクエスト時刻を引いたものを秒で 表すことで生成されます。

基準時刻はファイルの最終修正時刻か、クライアントのドキュメントへの アクセス時刻です。どちらを使うべきかは <code> によって指定します。M は基準時刻として ファイルの最終修正時刻をという意味で、A はクライアントの アクセス時刻を使うという意味になります。

効果には微妙な違いがあります。M が使用された場合は、 すべてのキャッシュにある現在のドキュメントキャッシュは同時に期限が 切れます。これは同じ URL に毎週常に置かれる報せのようなものには 非常に有効です。A が使用された場合は、期限切れの 時間は各クライアントによって異なります。これはあまり変更されない 画像ファイルなど、特に関連するドキュメント群がすべて同じ画像を 参照するとき (すなわち画像が比較的短い期間内に繰り返し アクセスされるとき) に有効です。

例:

# enable expirations
ExpiresActive On
# expire GIF images after a month in the client's cache
ExpiresByType image/gif A2592000
# HTML documents are good for a week from the
# time they were changed
ExpiresByType text/html M604800

このディレクティブは ExpiresActive On が指定されている ときのみ有効であることに注意してください。これは、 指定された MIME タイプに対してのみ ExpiresDefault ディレクティブで 設定された期限切れ期日を上書きします。

この文書の前の方で説明されている代替構文を 使って期限切れ期日の計算方法を指定することもできます。

top

ExpiresDefault ディレクティブ

説明:期限切れ期日を計算するデフォルトアルゴリズム
構文:ExpiresDefault <code>seconds
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Indexes
ステータス:Extension
モジュール:mod_expires

このディレクティブは対応する範囲のすべてのドキュメントに対して デフォルトの期限切れ期日の計算アルゴリズムを設定します。ExpiresByType ディレクティブによって タイプ毎に上書きすることができます。引数の構文はそのディレクティブの 説明を参照してください。また、代替構文も 参照してください。

mod/mod_ext_filter.html100644 0 0 45651 11237400230 12701 0ustar 0 0 mod_ext_filter - Apache HTTP サーバ
<-

Apache モジュール mod_ext_filter

This translation may be out of date. Check the English version for recent changes.
説明:レスポンスのボディをクライアントに送る前に外部プログラムで処理する
ステータス:Extension
モジュール識別子:ext_filter_module
ソースファイル:mod_ext_filter.c

概要

mod_ext_filter では フィルタ の慣れ親しんだ単純なプログラミングモデルが提供されます。このモジュールを 使えば、標準入力から読み込んで、標準出力に書き出すプログラム (すなわち Unix 形式のフィルタコマンド) を Apache のフィルタにすることが できます。このフィルタの機構は、Apache API 向けに書かれた Apache サーバプロセス内で実行される専用のフィルタよりもずっと遅いですが、 以下のような利点もあります。

  • ずっとシンプルなプログラミングモデル
  • プログラムが標準入力から読んで標準出力に書くものである限り、 どんなプログラム言語やスクリプト言語でも使うことができる
  • 既存のプログラムを変更することなく Apache のフィルタとして 使うことができる

性能の問題により実運用に適さないとしても、フィルタのプロトタイプ用の 環境としては mod_ext_filter は使えます。

ディレクティブ

トピック

参照

top

他のタイプのレスポンスから HTML を生成する

# mod_ext_filter directive to define a filter
# to HTML-ize text/c files using the external
# program /usr/bin/enscript, with the type of
# the result set to text/html
ExtFilterDefine c-to-html mode=output \
intype=text/c outtype=text/html \
cmd="/usr/bin/enscript --color -W html -Ec -o - -"

<Directory "/export/home/trawick/apacheinst/htdocs/c">
# core directive to cause the new filter to
# be run on output
SetOutputFilter c-to-html

# mod_mime directive to set the type of .c
# files to text/c
AddType text/c .c

# mod_ext_filter directive to set the debug
# level just high enough to see a log message
# per request showing the configuration in force
ExtFilterOptions DebugLevel=1
</Directory>

コンテントエンコーディングのフィルタを実装する

注: この gzip の例はデモ用です。実用的な実装は mod_deflate を参照してください。

# mod_ext_filter directive to define the external filter
ExtFilterDefine gzip mode=output cmd=/bin/gzip

<Location /gzipped>
# core directive to cause the gzip filter to be
# run on output
SetOutputFilter gzip

# mod_header directive to add
# "Content-Encoding: gzip" header field
Header set Content-Encoding gzip
</Location>

サーバを遅くする

# mod_ext_filter directive to define a filter
# which runs everything through cat; cat doesn't
# modify anything; it just introduces extra pathlength
# and consumes more resources
ExtFilterDefine slowdown mode=output cmd=/bin/cat \
preservescontentlength

<Location />
# core directive to cause the slowdown filter to
# be run several times on output
#
SetOutputFilter slowdown;slowdown;slowdown
</Location>

sed を使って応答中のテキストを置換する

# mod_ext_filter directive to define a filter which
# replaces text in the response
#
ExtFilterDefine fixtext mode=output intype=text/html \
cmd="/bin/sed s/verdana/arial/g"

<Location />
# core directive to cause the fixtext filter to
# be run on output
SetOutputFilter fixtext
</Location>

別のフィルタのトレース

# Trace the data read and written by mod_deflate
# for a particular client (IP 192.168.1.31)
# experiencing compression problems.
# This filter will trace what goes into mod_deflate.
ExtFilterDefine tracebefore \
cmd="/bin/tracefilter.pl /tmp/tracebefore" \
EnableEnv=trace_this_client

# This filter will trace what goes after mod_deflate.
# Note that without the ftype parameter, the default
# filter type of AP_FTYPE_RESOURCE would cause the
# filter to be placed *before* mod_deflate in the filter
# chain. Giving it a numeric value slightly higher than
# AP_FTYPE_CONTENT_SET will ensure that it is placed
# after mod_deflate.
ExtFilterDefine traceafter \
cmd="/bin/tracefilter.pl /tmp/traceafter" \
EnableEnv=trace_this_client ftype=21

<Directory /usr/local/docs>
SetEnvIf Remote_Addr 192.168.1.31 trace_this_client
SetOutputFilter tracebefore;deflate;traceafter
</Directory>

データをトレースするフィルタ:

#!/usr/local/bin/perl -w
use strict;

open(SAVE, ">$ARGV[0]")
or die "can't open $ARGV[0]: $?";

while (<STDIN>) {
print SAVE $_;
print $_;
}

close(SAVE);

top

ExtFilterDefine ディレクティブ

説明:外部フィルタを定義
構文:ExtFilterDefine filtername parameters
コンテキスト:サーバ設定ファイル
ステータス:Extension
モジュール:mod_ext_filter

ExtFilterDefine は、実行するプログラムや 引数など、外部フィルタの特性を定義します。

filtername は定義するフィルタの名前を指定します。 この名前は後で SetOutputFilter ディレクティブで指定できます。名前は登録されるすべてのフィルタで 一意でなくてはなりません。現時点では、フィルタの登録 API からは エラーは報告されません。ですから、重複する名前を使ってしまったときでも ユーザにはそのことは報告されません。

続くパラメータの順番は関係無く、それらは実行する外部コマンドと、 他の特性を定義します。cmd= だけが必須のパラメータです。 指定可能なパラメータは:

cmd=cmdline
cmd= キーワードは実行する外部コマンドを指定します。 プログラム名の後に引数がある場合は、コマンド行は引用符で囲む 必要があります (例えばcmd="/bin/mypgm arg1 arg2" のように)。プログラムは シェル経由でなく、直接実行されますので、通常のシェル用の エスケープは必要ありません。プログラムの引数は空白で区切られます。 プログラムの引数の一部となる必要のある空白はバックスペースでエスケープ できます。引数の一部になるバックスラッシュはバックスラッシュで エスケープする必要があります。標準の CGI 環境変数に加えて、 環境変数 DOCUMENT_URI, DOCUMENT_PATH_INFO, and QUERY_STRING_UNESCAPED がプログラムのために設定されます。
mode=mode
応答を処理するフィルタには mode=output (デフォルト) を使います。リクエストを処理するフィルタには mode=input を使います。mode=input は Apache 2.1 以降で使用できます。
intype=imt
このパラメータはフィルタされるべきドキュメントの インターネットメディアタイプ (すなわち、MIME タイプ) を 指定します。デフォルトではすべてのドキュメントがフィルタされます。 intype= が指定されていれば、フィルタは指定されていない ドキュメントには適用されなくなります。
outtype=imt
このパラメータはフィルタされたドキュメントの インターネットメディアタイプ (すなわち、MIME タイプ) を 指定します。フィルタ動作にともなってインターネットメディアタイプが 変わる場合に有用です。デフォルトではインターネットメディアタイプは 変更されません。
PreservesContentLength
PreservesContentLength キーワードはフィルタが content length (訳注: コンテントの長さ) を変更しないということを指定します。ほとんどのフィルタは content length を変更するため、これはデフォルトではありません。 フィルタが長さを変えないときは、このキーワードを指定すると よいでしょう。
ftype=filtertype
このパラメータはフィルタが登録されるべきフィルタタイプの 数値を指定します。ほとんどの場合は、デフォルトの AP_FTYPE_RESOURCE で 十分です。フィルタがフィルタチェーンの別の場所で動作する必要がある 場合は、このパラメータを指定する必要があります。指定可能な値は util_filter.h の AP_FTYPE_foo 定義を参照してください。
disableenv=env
設定されていた場合にフィルタを無効にするための環境変数を 指定します。
enableenv=env
このパラメータはフィルタが有効になるために設定されていなければ ならない環境変数を指定します。
top

ExtFilterOptions ディレクティブ

説明:mod_ext_filter のオプションを設定
構文:ExtFilterOptions option [option] ...
デフォルト:ExtFilterOptions DebugLevel=0 NoLogStderr
コンテキスト:ディレクトリ
ステータス:Extension
モジュール:mod_ext_filter

ExtFilterOptions ディレクティブは mod_ext_filter の特別な処理用のオプションを 指定します。Option には以下のどれかを指定します。

DebugLevel=n
DebugLevelmod_ext_filter の生成するデバッグメッセージのレベルを設定できます。 デフォルトでは、デバッグメッセージは生成されません。 これは DebugLevel=0 と設定するのと同じです。 数字が大きくなればなるほど、より多くのデバッグメッセージが 生成され、サーバの性能は落ちます。数値の実際の意味は mod_ext_filter.c の先頭近くの DBGLVL_ 定数の 定義で説明されています。

注: デバッグメッセージを Apache のエラーログに 保存するようにするためには、core のディレクティブ LogLevel を使う必要があります。

LogStderr | NoLogStderr
LogStderr キーワードは外部フィルタプログラムにより 標準エラー (訳注: stderr) に書かれたメッセージを Apache のエラーログに保存するようにします。NoLogStderr は 逆に保存しないようにします。

ExtFilterOptions LogStderr DebugLevel=0

この例では、フィルタの標準出力に書かれたメッセージは Apache のエラーログに保存されます。mod_ext_filter からは デバッグメッセージは生成されません。

mod/mod_file_cache.html100644 0 0 27402 11237400230 12570 0ustar 0 0 mod_file_cache - Apache HTTP Server
<-

Apache Module mod_file_cache

Description:Caches a static list of files in memory
Status:Experimental
ModuleIdentifier:file_cache_module
SourceFile:mod_file_cache.c

Summary

This module should be used with care. You can easily create a broken site using mod_file_cache, so read this document carefully.

Caching frequently requested files that change very infrequently is a technique for reducing server load. mod_file_cache provides two techniques for caching frequently requested static files. Through configuration directives, you can direct mod_file_cache to either open then mmap() a file, or to pre-open a file and save the file's open file handle. Both techniques reduce server load when processing requests for these files by doing part of the work (specifically, the file I/O) for serving the file when the server is started rather than during each request.

Notice: You cannot use this for speeding up CGI programs or other files which are served by special content handlers. It can only be used for regular files which are usually served by the Apache core content handler.

This module is an extension of and borrows heavily from the mod_mmap_static module in Apache 1.3.

top

Using mod_file_cache

mod_file_cache caches a list of statically configured files via MMapFile or CacheFile directives in the main server configuration.

Not all platforms support both directives. You will receive an error message in the server error log if you attempt to use an unsupported directive. If given an unsupported directive, the server will start but the file will not be cached. On platforms that support both directives, you should experiment with both to see which works best for you.

MMapFile Directive

The MMapFile directive of mod_file_cache maps a list of statically configured files into memory through the system call mmap(). This system call is available on most modern Unix derivates, but not on all. There are sometimes system-specific limits on the size and number of files that can be mmap()ed, experimentation is probably the easiest way to find out.

This mmap()ing is done once at server start or restart, only. So whenever one of the mapped files changes on the filesystem you have to restart the server (see the Stopping and Restarting documentation). To reiterate that point: if the files are modified in place without restarting the server you may end up serving requests that are completely bogus. You should update files by unlinking the old copy and putting a new copy in place. Most tools such as rdist and mv do this. The reason why this modules doesn't take care of changes to the files is that this check would need an extra stat() every time which is a waste and against the intent of I/O reduction.

CacheFile Directive

The CacheFile directive of mod_file_cache opens an active handle or file descriptor to the file (or files) listed in the configuration directive and places these open file handles in the cache. When the file is requested, the server retrieves the handle from the cache and passes it to the sendfile() (or TransmitFile() on Windows), socket API.

This file handle caching is done once at server start or restart, only. So whenever one of the cached files changes on the filesystem you have to restart the server (see the Stopping and Restarting documentation). To reiterate that point: if the files are modified in place without restarting the server you may end up serving requests that are completely bogus. You should update files by unlinking the old copy and putting a new copy in place. Most tools such as rdist and mv do this.

Note

Don't bother asking for a directive which recursively caches all the files in a directory. Try this instead... See the Include directive, and consider this command:

find /www/htdocs -type f -print \
| sed -e 's/.*/mmapfile &/' > /www/conf/mmap.conf

top

CacheFile Directive

Description:Cache a list of file handles at startup time
Syntax:CacheFile file-path [file-path] ...
Context:server config
Status:Experimental
Module:mod_file_cache

The CacheFile directive opens handles to one or more files (given as whitespace separated arguments) and places these handles into the cache at server startup time. Handles to cached files are automatically closed on a server shutdown. When the files have changed on the filesystem, the server should be restarted to re-cache them.

Be careful with the file-path arguments: They have to literally match the filesystem path Apache's URL-to-filename translation handlers create. We cannot compare inodes or other stuff to match paths through symbolic links etc. because that again would cost extra stat() system calls which is not acceptable. This module may or may not work with filenames rewritten by mod_alias or mod_rewrite.

Example

CacheFile /usr/local/apache/htdocs/index.html

top

MMapFile Directive

Description:Map a list of files into memory at startup time
Syntax:MMapFile file-path [file-path] ...
Context:server config
Status:Experimental
Module:mod_file_cache

The MMapFile directive maps one or more files (given as whitespace separated arguments) into memory at server startup time. They are automatically unmapped on a server shutdown. When the files have changed on the filesystem at least a HUP or USR1 signal should be send to the server to re-mmap() them.

Be careful with the file-path arguments: They have to literally match the filesystem path Apache's URL-to-filename translation handlers create. We cannot compare inodes or other stuff to match paths through symbolic links etc. because that again would cost extra stat() system calls which is not acceptable. This module may or may not work with filenames rewritten by mod_alias or mod_rewrite.

Example

MMapFile /usr/local/apache/htdocs/index.html

mod/mod_filter.html100644 0 0 61465 11237400230 12022 0ustar 0 0 mod_filter - Apache HTTP Server
<-

Apache Module mod_filter

Description:Context-sensitive smart filter configuration module
Status:Base
ModuleIdentifier:filter_module
SourceFile:mod_filter.c
Compatibility:Version 2.1 and later

Summary

This module enables smart, context-sensitive configuration of output content filters. For example, apache can be configured to process different content-types through different filters, even when the content-type is not known in advance (e.g. in a proxy).

mod_filter works by introducing indirection into the filter chain. Instead of inserting filters in the chain, we insert a filter harness which in turn dispatches conditionally to a filter provider. Any content filter may be used as a provider to mod_filter; no change to existing filter modules is required (although it may be possible to simplify them).

top

Smart Filtering

In the traditional filtering model, filters are inserted unconditionally using AddOutputFilter and family. Each filter then needs to determine whether to run, and there is little flexibility available for server admins to allow the chain to be configured dynamically.

mod_filter by contrast gives server administrators a great deal of flexibility in configuring the filter chain. In fact, filters can be inserted based on any Request Header, Response Header or Environment Variable. This generalises the limited flexibility offered by AddOutputFilterByType, and fixes it to work correctly with dynamic content, regardless of the content generator. The ability to dispatch based on Environment Variables offers the full flexibility of configuration with mod_rewrite to anyone who needs it.

top

Filter Declarations, Providers and Chains

[This image displays the traditional filter model]
Figure 1: The traditional filter model

In the traditional model, output filters are a simple chain from the content generator (handler) to the client. This works well provided the filter chain can be correctly configured, but presents problems when the filters need to be configured dynamically based on the outcome of the handler.

[This image shows the mod_filter model]
Figure 2: The mod_filter model

mod_filter works by introducing indirection into the filter chain. Instead of inserting filters in the chain, we insert a filter harness which in turn dispatches conditionally to a filter provider. Any content filter may be used as a provider to mod_filter; no change to existing filter modules is required (although it may be possible to simplify them). There can be multiple providers for one filter, but no more than one provider will run for any single request.

A filter chain comprises any number of instances of the filter harness, each of which may have any number of providers. A special case is that of a single provider with unconditional dispatch: this is equivalent to inserting the provider filter directly into the chain.

top

Configuring the Chain

There are three stages to configuring a filter chain with mod_filter. For details of the directives, see below.

Declare Filters
The FilterDeclare directive declares a filter, assigning it a name and filter type. Required only if the filter is not the default type AP_FTYPE_RESOURCE.
Register Providers
The FilterProvider directive registers a provider with a filter. The filter may have been declared with FilterDeclare; if not, FilterProvider will implicitly declare it with the default type AP_FTYPE_RESOURCE. The provider must have been registered with ap_register_output_filter by some module. The remaining arguments to FilterProvider are a dispatch criterion and a match string. The former may be an HTTP request or response header, an environment variable, or the Handler used by this request. The latter is matched to it for each request, to determine whether this provider will be used to implement the filter for this request.
Configure the Chain
The above directives build components of a smart filter chain, but do not configure it to run. The FilterChain directive builds a filter chain from smart filters declared, offering the flexibility to insert filters at the beginning or end of the chain, remove a filter, or clear the chain.
top

Examples

Server side Includes (SSI)
A simple case of using mod_filter in place of AddOutputFilterByType

FilterDeclare SSI
FilterProvider SSI INCLUDES resp=Content-Type $text/html
FilterChain SSI

Server side Includes (SSI)
The same as the above but dispatching on handler (classic SSI behaviour; .shtml files get processed).

FilterProvider SSI INCLUDES Handler server-parsed
FilterChain SSI

Emulating mod_gzip with mod_deflate
Insert INFLATE filter only if "gzip" is NOT in the Accept-Encoding header. This filter runs with ftype CONTENT_SET.

FilterDeclare gzip CONTENT_SET
FilterProvider gzip inflate req=Accept-Encoding !$gzip
FilterChain gzip

Image Downsampling
Suppose we want to downsample all web images, and have filters for GIF, JPEG and PNG.

FilterProvider unpack jpeg_unpack Content-Type $image/jpeg
FilterProvider unpack gif_unpack Content-Type $image/gif
FilterProvider unpack png_unpack Content-Type $image/png

FilterProvider downsample downsample_filter Content-Type $image
FilterProtocol downsample "change=yes"

FilterProvider repack jpeg_pack Content-Type $image/jpeg
FilterProvider repack gif_pack Content-Type $image/gif
FilterProvider repack png_pack Content-Type $image/png
<Location /image-filter>
FilterChain unpack downsample repack
</Location>

top

Protocol Handling

Historically, each filter is responsible for ensuring that whatever changes it makes are correctly represented in the HTTP response headers, and that it does not run when it would make an illegal change. This imposes a burden on filter authors to re-implement some common functionality in every filter:

  • Many filters will change the content, invalidating existing content tags, checksums, hashes, and lengths.
  • Filters that require an entire, unbroken response in input need to ensure they don't get byteranges from a backend.
  • Filters that transform output in a filter need to ensure they don't violate a Cache-Control: no-transform header from the backend.
  • Filters may make responses uncacheable.

mod_filter aims to offer generic handling of these details of filter implementation, reducing the complexity required of content filter modules. This is work-in-progress; the FilterProtocol implements some of this functionality for back-compatibility with Apache 2.0 modules. For httpd 2.1 and later, the ap_register_output_filter_protocol and ap_filter_protocol API enables filter modules to declare their own behaviour.

At the same time, mod_filter should not interfere with a filter that wants to handle all aspects of the protocol. By default (i.e. in the absence of any FilterProtocol directives), mod_filter will leave the headers untouched.

At the time of writing, this feature is largely untested, as modules in common use are designed to work with 2.0. Modules using it should test it carefully.

top

FilterChain Directive

Description:Configure the filter chain
Syntax:FilterChain [+=-@!]filter-name ...
Context:server config, virtual host, directory, .htaccess
Override:Options
Status:Base
Module:mod_filter

This configures an actual filter chain, from declared filters. FilterChain takes any number of arguments, each optionally preceded with a single-character control that determines what to do:

+filter-name
Add filter-name to the end of the filter chain
@filter-name
Insert filter-name at the start of the filter chain
-filter-name
Remove filter-name from the filter chain
=filter-name
Empty the filter chain and insert filter-name
!
Empty the filter chain
filter-name
Equivalent to +filter-name
top

FilterDeclare Directive

Description:Declare a smart filter
Syntax:FilterDeclare filter-name [type]
Context:server config, virtual host, directory, .htaccess
Override:Options
Status:Base
Module:mod_filter

This directive declares an output filter together with a header or environment variable that will determine runtime configuration. The first argument is a filter-name for use in FilterProvider, FilterChain and FilterProtocol directives.

The final (optional) argument is the type of filter, and takes values of ap_filter_type - namely RESOURCE (the default), CONTENT_SET, PROTOCOL, TRANSCODE, CONNECTION or NETWORK.

top

FilterProtocol Directive

Description:Deal with correct HTTP protocol handling
Syntax:FilterProtocol filter-name [provider-name] proto-flags
Context:server config, virtual host, directory, .htaccess
Override:Options
Status:Base
Module:mod_filter

This directs mod_filter to deal with ensuring the filter doesn't run when it shouldn't, and that the HTTP response headers are correctly set taking into account the effects of the filter.

There are two forms of this directive. With three arguments, it applies specifically to a filter-name and a provider-name for that filter. With two arguments it applies to a filter-name whenever the filter runs any provider.

proto-flags is one or more of

change=yes
The filter changes the content, including possibly the content length
change=1:1
The filter changes the content, but will not change the content length
byteranges=no
The filter cannot work on byteranges and requires complete input
proxy=no
The filter should not run in a proxy context
proxy=transform
The filter transforms the response in a manner incompatible with the HTTP Cache-Control: no-transform header.
cache=no
The filter renders the output uncacheable (eg by introducing randomised content changes)
top

FilterProvider Directive

Description:Register a content filter
Syntax:FilterProvider filter-name provider-name [req|resp|env]=dispatch match
Context:server config, virtual host, directory, .htaccess
Override:Options
Status:Base
Module:mod_filter

This directive registers a provider for the smart filter. The provider will be called if and only if the match declared here matches the value of the header or environment variable declared as dispatch.

provider-name must have been registered by loading a module that registers the name with ap_register_output_filter.

The dispatch argument is a string with optional req=, resp= or env= prefix causing it to dispatch on (respectively) the request header, response header, or environment variable named. In the absence of a prefix, it defaults to a response header. A special case is the word handler, which causes mod_filter to dispatch on the content handler.

The match argument specifies a match that will be applied to the filter's dispatch criterion. The match may be a string match (exact match or substring), a regex, an integer (greater, lessthan or equals), or unconditional. The first characters of the match argument determines this:

First, if the first character is an exclamation mark (!), this reverses the rule, so the provider will be used if and only if the match fails.

Second, it interprets the first character excluding any leading ! as follows:

CharacterDescription
(none)exact match
$substring match
/regex match (delimited by a second /)
=integer equality
<integer less-than
<=integer less-than or equal
>integer greater-than
>=integer greater-than or equal
*Unconditional match
top

FilterTrace Directive

Description:Get debug/diagnostic information from mod_filter
Syntax:FilterTrace filter-name level
Context:server config, virtual host, directory
Status:Base
Module:mod_filter

This directive generates debug information from mod_filter. It is designed to help test and debug providers (filter modules), although it may also help with mod_filter itself.

The debug output depends on the level set:

0 (default)
No debug information is generated.
1
mod_filter will record buckets and brigades passing through the filter to the error log, before the provider has processed them. This is similar to the information generated by mod_diagnostics.
2 (not yet implemented)
Will dump the full data passing through to a tempfile before the provider. For single-user debug only; this will not support concurrent hits.
mod/mod_headers.html100644 0 0 52036 11237400230 12142 0ustar 0 0 mod_headers - Apache HTTP サーバ
<-

Apache モジュール mod_headers

This translation may be out of date. Check the English version for recent changes.
説明:HTTP リクエストのヘッダと応答のヘッダのカスタマイズ
ステータス:Extension
モジュール識別子:headers_module
ソースファイル:mod_headers.c

概要

このモジュールは HTTP のリクエストヘッダと応答ヘッダを制御し、 変更するためのディレクティブを提供します。ヘッダを追加したり、 置き換えたり、削除したりすることができます。

top

処理の順番

mod_header のディレクティブはサーバ設定のほぼどこにでも 書くことができ、影響する範囲を設定用セクションで囲むことで限定する ことができます。

処理の順番は重要で、設定ファイル中の順番と、設定用セクション内の位置との両方に 影響されます。以下の二つのヘッダは順番が逆になると 違う結果になります:

RequestHeader append MirrorID "mirror 12"
RequestHeader unset MirrorID

この順番の場合は、MirrorID ヘッダは設定されません。 逆になっていると、MirrorID ヘッダは "mirror 12" に設定されます。

top

早期処理、後期処理

mod_headers では、リクエストの早期か後期かの どちらで適用するかを選べます。通常は後期モードで、 コンテンツ生成が実行される直前にリクエストヘッダがセットされ、 レスポンスとして送出される直前にレスポンスヘッダがセットされます。 運用中のサーバでは必ず後期モードを使ってください。

早期モードは開発者向けのテスト/デバッグ用に設計されています。 early キーワード指定されたディレクティブによって、 リクエスト処理の開始地点になります。 つまり、異なるリクエストを試したりテストケースをセットアップするのに 活用できる一方で、レスポンスを生成する前に他のモジュールによって ヘッダが書き換えられてしまうかもしれないということを意味します。

early ディレクティブではリクエストパスの設定が解決される前に 処理されるので、メインサーバかバーチャルホストコンテキストでのみ、 早期ヘッダをセットできます。early ディレクティブはリクエストパスに 依存することはできませんので、<Directory><Location> といったコンテキスト内では使用 できません。

top

  1. リクエストヘッダ中の "TS" で始まるフィールドをすべて応答ヘッダに コピーします:

    Header echo ^TS

  2. リクエストを受け付けた時刻とリクエストを処理した時間を入れたヘッダ、 MyHeader を応答に追加します。このヘッダはクライアントが サーバの負荷を直観的に知るためや、クライアント-サーバ間の ボトルネックを調べるために使うことができます。

    Header add MyHeader "%D %t"

    上記の設定では、以下のようなヘッダが応答に追加されることになります:

    MyHeader: D=3775428 t=991424704447256

  3. Joe にあいさつをします:

    Header add MyHeader "Hello Joe. It took %D microseconds for Apache to serve this request."

    以下のようなヘッダが応答に追加されることになります

    MyHeader: Hello Joe. It took D=3775428 microseconds for Apache to serve this request.

  4. リクエストに "MyRequestHeader" があるときに限り MyHeader を応答に 付けます。これは、クライアントの要求に応えてヘッダを作成するときに 役に立ちます。この例では mod_setenvif モジュールが必要なことに 注意してください。

    SetEnvIf MyRequestHeader value HAVE_MyRequestHeader
    Header add MyHeader "%D %t mytext" env=HAVE_MyRequestHeader

    もし HTTP リクエストに MyRequestHeader: value ヘッダが あると、応答には以下のようなヘッダが付加されます。

    MyHeader: D=3775428 t=991424704447256 mytext

top

Header ディレクティブ

説明:HTTP 応答ヘッダの設定
構文:Header [condition] set|append|add|unset|echo header [value] [early|env=[!]variable]
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Extension
モジュール:mod_headers

このディレクティブは HTTP 応答ヘッダを置換、追加、削除できます。 ヘッダはコンテントハンドラや出力フィルタが実行された直後に実行され、 出て行くヘッダを変更できるようになっています。

オプションの conditiononsuccessalways のどちらかを指定できます。これは内部ヘッダテーブルのどれを 操作するかを決定します。onsuccess2xx ステータスコードの、always は全てのステータスコード (2xx を含む) の意味になります。 あるモジュールでセットされるヘッダをアンセットしたい場合は特に、 どのテーブルが影響を受けるかを実際に試したほうがよいでしょう。

行なう処理は二番目のの引数で決まります。 この引数には次の値を指定できます:

set
応答ヘッダを設定します。同じ名前のヘッダが存在する場合はそれを 置き換えます。value にはフォーマット文字列を 指定することもできます。
append
応答ヘッダを既に存在する同じ名前のヘッダに追加します。 新しい値が既存のヘッダに追加されるときには、既存のヘッダの 後にコンマで区切られて追加されます。これはヘッダに複数の値を 指定するときの HTTP の標準の方法です。
add
ヘッダが既に存在しているときでさえも、応答ヘッダを 既存のヘッダに追加します。これにより、二つ (かそれ以上) の ヘッダの名前が同じになることがあります。その結果、想定できない ことが起こる可能性がありますので、一般的には append の方を 使う方が良いでしょう。
unset
もし指定された名前の応答ヘッダが存在していれば、削除されます。 同じ名前のヘッダが複数あるときは、すべて削除されます。 value をつけてはいけません。
echo
指定されたものと同じ名前のリクエストヘッダを応答ヘッダで そのまま返します。header には正規表現も指定できます。 value をつけてはいけません。

この引数の後にはヘッダ名 (header) が続きます。 ヘッダ名には最後にコロンを含めることもできますが、無くても構いません。 set, append, add, unset では大文字小文字は 区別されません。echo の header 名は大文字小文字を区別し、 正規表現を指定することもできます。

add, append, set では value を三つ目の 引数として指定します。value に空白がある場合は二重引用符で 囲む必要があります。value は文字のみからなる文字列、 フォーマット指示子を含む文字列、もしくは両方からなる文字列を指定できます。 value は以下のフォーマット指示子をサポートします:

フォーマット解説
%% パーセント記号
%t リクエストを受け取った時刻を、 Universal Coordinated Time での始まりの時刻 (Jan. 1, 1970) から経過した 時間をマイクロ秒として表したもの。値の最初には t= が付加されます。
%D リクエストを受け取った時刻と、ヘッダを送り出した 時間との差。これは、リクエストが存在していた期間を表します。 値の最初には D= が付加されます。
%{FOOBAR}e 環境変数 FOOBAR の値です。
%{FOOBAR}s mod_ssl が有効な場合、 SSL 環境変数 FOOBAR の内容

%s フォーマット指定子は 2.1 以降でのみ利用できます。 SSLOptions +StdEnvVars を有効にすることによるオーバーヘッドを 避けるため、%e の代わりとして使えます。 他の理由などがあって、どうしても SSLOptions +StdEnvVars を有効にしなければならない場合は、%e のほうが %s よりも処理効率は良いです。

Header ディレクティブには追加の引数を持たせることが できて、どういったアクションが行われたかの条件を指定したり、 早期処理 を指定する early キーワードを 指定できます。 env=... 引数で指定された 環境変数 が存在する (もしくは env=!... が指定されていて環境変数が存在しない) 場合は、Header ディレクティブで指定された動作が行なわれます。そうでない場合は、 ディレクティブはそのリクエストには何もしません。

早期処理モードの場合以外では、 Header ディレクティブは応答がネットワークに送られる直前に 処理されます。これは、ヘッダフィルタにより追加されるヘッダを 除き、ほとんどのヘッダを設定したり上書きしたりすることが 可能、ということです。

top

RequestHeader ディレクティブ

説明:HTTP リクエストヘッダの設定
構文:RequestHeader set|append|add|unset header [value] [early|env=[!]variable]
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Extension
モジュール:mod_headers

このディレクティブは HTTP リクエストヘッダを置換、追加、削除できます。 ヘッダはコンテントハンドラが実行される直前に実行され、 入って来るヘッダを変更することが可能になっています。 行なう処理は第 1 引数により決まります。これには以下の値を指定 することができます:

set
リクエストヘッダを設定します。同じ名前のヘッダが存在していると、 それを置き換えます。
append
リクエストヘッダは、既に存在する同じ名前のヘッダに追加されます。 新しい値が既存のヘッダに追加されるときには、既存のヘッダの 後にコンマで区切られて追加されます。これはヘッダに複数の値を 指定するときの HTTP の標準の方法です。
add
ヘッダが既に存在しているときでさえも、リクエストヘッダを 既存のヘッダに追加します。これにより、二つ (かそれ以上) の ヘッダの名前が同じになることがあります。その結果、想定できない ことが起こる可能性がありますので、一般的には append の方を 使う方が良いでしょう。
unset
もし指定された名前のリクエストヘッダが存在していれば、削除されます。 同じ名前の複数のヘッダがあるときは、すべて削除されます。 value をつけてはいけません。

この引数の後にはヘッダ名 (header) が続きます。 ヘッダ名には最後にコロンを含めることもできますが、無くても構いません。 大文字小文字は区別されません。add, append, set の場合は、value が三つ目の 引数として指定されます。value に空白がある場合は二重引用符で 囲む必要があります。unset の場合は、value は指定しません。 value は文字列、フォーマット指定子、あるいは、その混合です。 使うことのできるフォーマット指定子は、Header と同じですので、 詳細はそちらをご覧ください。

RequestHeader ディレクティブは、 どういった条件下でアクションを行うかを指定する追加引数 あるいは、早期処理 を指定する early キーワードを設定することができます。 env=... の引数で設定されている 環境変数 が存在している (あるいは env=!... で指定された環境変数が 存在しない) 場合、RequestHeader ディレクティブは 有効になります。それ以外の場合、ディレクティブは効力を持ちません。

early モードでない場合に限り、 RequestHeader ディレクティブは fixup フェーズでリクエストがハンドラに扱われる直前に 処理されます。これにより、ブラウザや Apache の入力フィルタにより 生成されたヘッダを上書きしたり修正したりできるようになっています。

mod/mod_ident.html100644 0 0 16117 11237400230 11632 0ustar 0 0 mod_ident - Apache HTTP サーバ
<-

Apache モジュール mod_ident

説明:RFC 1413 ident lookups
ステータス:Extension
モジュール識別子:ident_module
ソースファイル:mod_ident.c
互換性:Apache 2.1 で使用可能

概要

このモジュールはリモートホストの RFC 1413 互換デーモン にコネクションの所有者を訊きます。

ディレクティブ

参照

top

IdentityCheck ディレクティブ

説明:リモートユーザの RFC 1413 によるアイデンティティのロギングを 有効にする
構文:IdentityCheck On|Off
デフォルト:IdentityCheck Off
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ
ステータス:Extension
モジュール:mod_ident
互換性:Apache 2.1 で core から移動

このディレクティブは、クライアントマシン上で identd やそれに類似したデーモンが動作しているときに、 それぞれの接続に対して RFC 1413 に準処したリモートユーザの 名前のロギングを行なうようにします。 この情報は、%...l フォーマット文字列を使ってアクセスログに収集されます。

ここで得られた情報は簡単なユーザ追跡に使う以外は、 まったく信頼するべきではありません。

すべてのリクエストに対してルックアップが行なわれますので、 深刻な遅延の問題を起こすかもしれないことに注意してください。 (訳注: 例えばクライアント側に) ファイアウォールやプロキシサーバがあると、 ルックアップが失敗し、各リクエストに IdentityCheckTimeoutで定義されている遅延が加わることに なる可能性があります。 従って、一般的にはインターネットからアクセス可能なパブリックなサーバで 有益なものではありません。

top

IdentityCheckTimeout ディレクティブ

説明:Ident リクエストがタイムアウトするまでの期間を決める
構文:IdentityCheckTimeout seconds
デフォルト:IdentityCheckTimeout 30
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ
ステータス:Extension
モジュール:mod_ident

このディレクティブは ident リクエストのタイムアウト時間を決めます。 デフォルトの値である 30 秒は、主にネットワーク遅延の考慮のために RFC 1413 により 推奨されています。しかし、おそらくローカルネットワークの速度に 合わせてタイムアウト値を調節するのがよいでしょう。

mod/mod_imagemap.html100644 0 0 43020 11237400230 12300 0ustar 0 0 mod_imagemap - Apache HTTP Server
<-

Apache Module mod_imagemap

Description:Server-side imagemap processing
Status:Base
ModuleIdentifier:imagemap_module
SourceFile:mod_imagemap.c

Summary

This module processes .map files, thereby replacing the functionality of the imagemap CGI program. Any directory or document type configured to use the handler imap-file (using either AddHandler or SetHandler) will be processed by this module.

The following directive will activate files ending with .map as imagemap files:

AddHandler imap-file map

Note that the following is still supported:

AddType application/x-httpd-imap map

However, we are trying to phase out "magic MIME types" so we are deprecating this method.

top

New Features

The imagemap module adds some new features that were not possible with previously distributed imagemap programs.

  • URL references relative to the Referer: information.
  • Default <base> assignment through a new map directive base.
  • No need for imagemap.conf file.
  • Point references.
  • Configurable generation of imagemap menus.
top

Imagemap File

The lines in the imagemap files can have one of several formats:

directive value [x,y ...]
directive value "Menu text" [x,y ...]
directive value x,y ... "Menu text"

The directive is one of base, default, poly, circle, rect, or point. The value is an absolute or relative URL, or one of the special values listed below. The coordinates are x,y pairs separated by whitespace. The quoted text is used as the text of the link if a imagemap menu is generated. Lines beginning with '#' are comments.

Imagemap File Directives

There are six directives allowed in the imagemap file. The directives can come in any order, but are processed in the order they are found in the imagemap file.

base Directive

Has the effect of <base href="value"> . The non-absolute URLs of the map-file are taken relative to this value. The base directive overrides ImapBase as set in a .htaccess file or in the server configuration files. In the absence of an ImapBase configuration directive, base defaults to http://server_name/.

base_uri is synonymous with base. Note that a trailing slash on the URL is significant.

default Directive
The action taken if the coordinates given do not fit any of the poly, circle or rect directives, and there are no point directives. Defaults to nocontent in the absence of an ImapDefault configuration setting, causing a status code of 204 No Content to be returned. The client should keep the same page displayed.
poly Directive
Takes three to one-hundred points, and is obeyed if the user selected coordinates fall within the polygon defined by these points.
circle
Takes the center coordinates of a circle and a point on the circle. Is obeyed if the user selected point is with the circle.
rect Directive
Takes the coordinates of two opposing corners of a rectangle. Obeyed if the point selected is within this rectangle.
point Directive
Takes a single point. The point directive closest to the user selected point is obeyed if no other directives are satisfied. Note that default will not be followed if a point directive is present and valid coordinates are given.

Values

The values for each of the directives can be any of the following:

a URL

The URL can be relative or absolute URL. Relative URLs can contain '..' syntax and will be resolved relative to the base value.

base itself will not be resolved according to the current value. A statement base mailto: will work properly, though.

map
Equivalent to the URL of the imagemap file itself. No coordinates are sent with this, so a menu will be generated unless ImapMenu is set to none.
menu
Synonymous with map.
referer
Equivalent to the URL of the referring document. Defaults to http://servername/ if no Referer: header was present.
nocontent
Sends a status code of 204 No Content, telling the client to keep the same page displayed. Valid for all but base.
error
Fails with a 500 Server Error. Valid for all but base, but sort of silly for anything but default.

Coordinates

0,0 200,200
A coordinate consists of an x and a y value separated by a comma. The coordinates are separated from each other by whitespace. To accommodate the way Lynx handles imagemaps, should a user select the coordinate 0,0, it is as if no coordinate had been selected.

Quoted Text

"Menu Text"

After the value or after the coordinates, the line optionally may contain text within double quotes. This string is used as the text for the link if a menu is generated:

<a href="http://example.com/">Menu text</a>

If no quoted text is present, the name of the link will be used as the text:

<a href="http://example.com/">http://example.com</a>

If you want to use double quotes within this text, you have to write them as &quot;.

top

Example Mapfile

#Comments are printed in a 'formatted' or 'semiformatted' menu.
#And can contain html tags. <hr>
base referer
poly map "Could I have a menu, please?" 0,0 0,10 10,10 10,0
rect .. 0,0 77,27 "the directory of the referer"
circle http://www.inetnebr.example.com/lincoln/feedback/ 195,0 305,27
rect another_file "in same directory as referer" 306,0 419,27
point http://www.zyzzyva.example.com/ 100,100
point http://www.tripod.example.com/ 200,200
rect mailto:nate@tripod.example.com 100,150 200,0 "Bugs?"

top

Referencing your mapfile

HTML example

<a href="/maps/imagemap1.map">
<img ismap src="/images/imagemap1.gif">
</a>

XHTML example

<a href="/maps/imagemap1.map">
<img ismap="ismap" src="/images/imagemap1.gif" />
</a>

top

ImapBase Directive

Description:Default base for imagemap files
Syntax:ImapBase map|referer|URL
Default:ImapBase http://servername/
Context:server config, virtual host, directory, .htaccess
Override:Indexes
Status:Base
Module:mod_imagemap

The ImapBase directive sets the default base used in the imagemap files. Its value is overridden by a base directive within the imagemap file. If not present, the base defaults to http://servername/.

See also

top

ImapDefault Directive

Description:Default action when an imagemap is called with coordinates that are not explicitly mapped
Syntax:ImapDefault error|nocontent|map|referer|URL
Default:ImapDefault nocontent
Context:server config, virtual host, directory, .htaccess
Override:Indexes
Status:Base
Module:mod_imagemap

The ImapDefault directive sets the default default used in the imagemap files. Its value is overridden by a default directive within the imagemap file. If not present, the default action is nocontent, which means that a 204 No Content is sent to the client. In this case, the client should continue to display the original page.

top

ImapMenu Directive

Description:Action if no coordinates are given when calling an imagemap
Syntax:ImapMenu none|formatted|semiformatted|unformatted
Context:server config, virtual host, directory, .htaccess
Override:Indexes
Status:Base
Module:mod_imagemap

The ImapMenu directive determines the action taken if an imagemap file is called without valid coordinates.

none
If ImapMenu is none, no menu is generated, and the default action is performed.
formatted
A formatted menu is the simplest menu. Comments in the imagemap file are ignored. A level one header is printed, then an hrule, then the links each on a separate line. The menu has a consistent, plain look close to that of a directory listing.
semiformatted
In the semiformatted menu, comments are printed where they occur in the imagemap file. Blank lines are turned into HTML breaks. No header or hrule is printed, but otherwise the menu is the same as a formatted menu.
unformatted
Comments are printed, blank lines are ignored. Nothing is printed that does not appear in the imagemap file. All breaks and headers must be included as comments in the imagemap file. This gives you the most flexibility over the appearance of your menus, but requires you to treat your map files as HTML instead of plaintext.
mod/mod_include.html100644 0 0 132670 11237400230 12175 0ustar 0 0 mod_include - Apache HTTP サーバ
<-

Apache モジュール mod_include

This translation may be out of date. Check the English version for recent changes.
説明:サーバがパースする html ドキュメント (Server Side Includes)
ステータス:Base
モジュール識別子:include_module
ソースファイル:mod_include.c
互換性:Apache 2.0 から出力フィルタとして実装されました。

概要

このモジュールはファイルがクライアントに送られる前に処理するフィルタを 提供します。処理の内容は要素と呼ばれる特別な形式の SGML コメントにより 制御されます。これらの要素は条件分岐や、他のファイルや プログラムの出力の取り込み、環境変数の設定や表示を行なうことが できます。

top

Server-Side Includes を有効にする

Server Side Includes は INCLUDES フィルタ により実装されています。 Server-side include のディレクティブを含むドキュメントの拡張子が .shtml の場合、以下のディレクティブでは Apache がそれらを パースして、その結果できるドキュメントに text/html の MIME タイプを割り当てます:

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

以下のディレクティブは shtml ファイルのあるディレクトリで指定されている 必要があります (通常は <Directory> セクションで指定しますが、 AllowOverride Options が設定されていると、.htaccess ファイルに書くこともできます):

Options +Includes

互換性を保つために、server-parsed ハンドラ も INCLUDES フィルタを 有効にします。MIME タイプ text/x-server-parsed-htmltext/x-server-parsed-html3 のドキュメントに対しても Apache は INCLUDES フィルタを有効にします (出力されるものは MIME タイプ text/html になります)。

詳しい情報は Server Side Includes チュートリアルを参照してください。

top

サーバサイドインクルード (SSI) での PATH_INFO

SSI で処理されるファイルはデフォルトでは PATH_INFO (後続のパス名情報) 付きのリクエストを受け入れなくなりました。AcceptPathInfo ディレクティブで PATH_INFO 付きのリクエストを受け入れるようにサーバを 設定できます。

top

基本要素

ドキュメントは、SGML のコメントとして特別なコマンドが埋め込まれた HTML ドキュメントとしてパースされます。コマンドの構文は次のように なっています:

<!--#element attribute=value attribute=value ... -->

値 (訳注: value) は二重引用符で囲むのが一般的ですが、 シングルクオート (') とバッククオート (`) も使用できます。 多くのコマンドは属性-値 (訳注: attribute-value) の組を一つだけ指定できます。 コメントの終わり (-->) の前には、SSI の句の一部だと解釈されないようにするために空白を 入れてください。最初の <!--# はまとめて一つの 句で、空白をふくんではいけないこと注意してください。

要素 (訳注: element) を以下の表に示します。

要素説明
config configure output formats
echo print variables
exec execute external programs
fsize print size of a file
flastmod print last modification time of a file
include include a file
printenv print all available variables
set set a value of a variable

SSI 要素は mod_include 以外のモジュールで 定義されることもあります。実際、 exec 要素は mod_cgi で提供されていて、このモジュールが ロードされる場合にのみ利用可能となります。

config 要素

次のコマンドは解析の様々な側面を制御します。属性は次の通りです。

echomsg (Apache 2.1 以降)
指定される値は、echo 要素が未定義の変数をエコーしようとした際に、 クライアントに送られるメッセージになります。 SSIUndefinedEcho ディレクティブを上書きします。
errmsg
この値が、ドキュメントの解析中にエラーが発生した時に クライアントに送信されるメッセージになります。 SSIErrorMsg ディレクティブを上書きします。
sizefmt
この値は、ファイルのサイズを表示する際に使用する フォーマットを設定します。値は バイトカウントの bytesか、Kb や Mb を優先的に使用する abbrec (例えば 1024 バイトは "1K" と表示されます) です。
timefmt
この値は strftime(3) ライブラリルーチンが 日時をプリントする際に用いられます。

echo 要素

このコマンドは以下で定義されている include 変数 を表示します。変数が設定されていない場合は SSIUndefinedEcho ディレクティブで 決定される結果となります。日付はその時点での timefmt に従って 表示されます。属性は次の通りです。

var
値は表示する変数の名前です。
encoding

変数を出力する前に、変数中の特別文字をどのようにエンコードするかを 指定します。none に設定されていると、エンコードは行なわれません。 url に設定されていると、URL エンコード (%-エンコードとも 呼ばれています。これはリンク等の URL の使用に適切です) が 行なわれます。echo 要素の開始時は、デフォルトは entity に設定されています。これはエンティティエンコード (段落やテキストなどのブロックレベルの HTML エレメントのコンテキストに 適しています) を行ないます。これは encoding 属性 を加えることで変更できます。変更は次の encoding 属性か、 要素の終了まで効力を持ちます。

encoding 属性はエンコードの変更をしたい var前に ある必要があることに注意してください。 また、ISO-8859-1 エンコーディングで 定義されている特別な文字だけがエンコードされます。 別の文字のエンコーディングの場合は、このエンコーディングは 望みの結果にならないかもしれません。

クロスサイトスクリプティングの問題を避けるために、 常にユーザからのデータをエンコードすべきです。

exec 要素

exec コマンドは指定されたシェルコマンドや CGI スクリプトを 実行します。mod_cgi がサーバに組み込まれているいなければ なりません。Options IncludesNOEXEC はこのコマンドを無効にします。 使用可能な属性は次の通りです。

cgi

値は (%-エンコードされた) URL を指定します。パスが スラッシュ (/) で始まらないときは、ドキュメントからの 相対パスとして扱われます。このパスで参照されているドキュメントは サーバが CGI スクリプトとして扱っていなくても CGI スクリプトとして 起動されます。ただし、スクリプトのあるディレクトリでは (ScriptAliasOptions ExecCGI によって) CGI スクリプトの使用が許可されている必要があります。

CGI スクリプトには、クライアントからの元々のリクエストの PATH_INFO とクエリー文字列 (QUERY_STRING) が渡されます。 これらは URL パスとして特定できないものです。 スクリプトは標準 CGI 環境に加えて、include 変数を 使用することができます。

<!--#exec cgi="/cgi-bin/example.cgi" -->

スクリプトが、出力の代わりに Location: ヘッダを返すと、 HTML のアンカー (訳注:リンク) に変換されます。

exec cgi よりも、 include virtual の方を使うようにしてください。特に、CGI への追加の引数を クエリー文字列を使って渡すことは exec cgi は できませんが、include virtual は以下のようにして 可能です。

<!--#include virtual="/cgi-bin/example.cgi?argument=value" -->

cmd

サーバは指定された文字列を /bin/sh を使って 実行します。コマンドは通常の CGI 変数に加えて include 変数も使うことができます。

ほとんどの場合、#include virtual を使う方が #exec cgi#exec cmd を使うよりも良いです。前者 (#include virtual) は標準の Apache のサブリクエスト機構を使ってファイルやスクリプトの 出力を取り込みます。 こちらの方がよくテストされメンテナンスされた方法です。

さらに、Win32 のようないくつかのプラットフォームや、suexec を使っている unix では、 exec ディレクティブのコマンドに 引数を渡したり、コマンドに空白を入れることはできません。 ですから、以下のものは unix の suexec でない設定では動作しますが、 Win32 や suexec を使っている unix では期待した結果にはなりません:

<!--#exec cmd="perl /path/to/perlscript arg1 arg2" -->

fsize 要素

このコマンドは指定されたファイルの大きさを sizefmt の 書式指定に基づいて出力します。属性は次の通りです。

file
値は解析されているドキュメントの存在するディレクトリからの 相対パスです。
virtual
値は (% エンコードされた) URL-path です。スラッシュ (/) で 始まらないときはドキュメントからの相対パスとして扱われます。 CGI の出力のサイズはプリントされません。CGI スクリプト自体のサイズがプリントされることに注意してください。

flastmod 要素

このコマンドは指定されたファイルの最終修正時刻を timefmt 書式指定に従って表示します。 指定可能な属性は fsize コマンドと同じです。

include 要素

このコマンドは別の文書やファイルのテキストを解析しているファイルに 挿入します。挿入されるファイルはアクセス制御の管理下にあります。 解析しているファイルの存在するディレクトリに Options IncludesNOEXEC が設定されている場合、text MIME タイプ (text/plain, text/html 等) のドキュメントのみインクルードが行なわれます。 その他の場合は、クエリー文字列も含め、コマンドで指定された 完全な URL を使って普通に CGI スクリプトが呼び出されます。

属性が文書の位置を指定します。include コマンドに与えられたそれぞれの 属性に対して挿入作業が行なわれます。有効な属性は次の通りです。

file
値は解析されているドキュメントの存在するディレクトリからの 相対パスです。 ../ を含んでいたり、絶対パスを指定したりはできません。 ですから、ドキュメントルートの外にあるファイルや、ディレクトリ構造で 上位にあるファイルを挿入することはできません。 常にこの属性よりは、virtual 属性を使うようにしてください。
virtual

値は解析されているドキュメントからの (% エンコードされた) URL です。URL にはスキームやホスト名を含めることはできません。パスと、 もしあればクエリー文字列を指定できるだけです。スラッシュ (/) から 始まらない場合は、ドキュメントからの相対パスとして扱われます。

URL は属性から作られ、その URL をクライアントがアクセスしたときに 出力される内容が解析後の出力に含められます。ですから、挿入される ファイルは入れ子構造にすることができます。

指定された URL が CGI プログラムであった場合は、 プログラムが実行され、その出力が解析しているファイル中の ディレクティブがあった位置に挿入されます。CGI の url に クエリー URL を入れることもできます。

<!--#include virtual="/cgi-bin/example.cgi?argument=value" -->

HTML ドキュメントに CGI プログラムの出力を含める方法としては、 include virtual の方が exec cgi よりも 好ましい方法です。

printenv 要素

これは、存在するすべての変数とその値を表示します。Apache 1.3.12 から、 特別な文字は出力される前にエンティティエンコード (詳細は echo 要素を参照) されるようになりました。属性はありません。

<!--#printenv -->

set 要素

これは変数の値を設定します。属性は次の通りです。

var
設定する変数の名前。
value
変数に設定する値。

<!--#set var="category" value="help" -->

top

Include 変数

標準 CGI 環境の変数に加えて、echo コマンドや、 ifelif, それにドキュメントから呼び出される すべてのプログラムから使用できる変数があります。

DATE_GMT
グリニッジ標準時による現在時刻。
DATE_LOCAL
ローカルの標準時による現在時刻。
DOCUMENT_NAME
ユーザがリクエストした (ディレクトリを除いた) ファイル名。
DOCUMENT_URI
ユーザがリクエストした (% エンコードされた) URL-path。 挿入ファイルが入れ子になっている場合は、解析されている ドキュメントの URL ではないことに注意してください。
LAST_MODIFIED
ユーザがリクエストしたドキュメントの最終修正時刻。
QUERY_STRING_UNESCAPED
クエリー文字列がある場合、この変数には (%-デコードされた) クエリー文字列が代入されていて、shell で使用できるように エスケープされています (& といった特殊文字にはバックスラッシュが直前に置かれます)。
top

変数置換

変数置換はたいていの場合 SSI ディレクティブの引数として妥当な場所にある 引用符で囲まれた文字列中で行なわれます。これに該当するものには、 config, exec, flastmod, fsize, include, echo, set の 各ディレクティブと、条件分岐用のオペレータへの引数があります。 ドル記号はバックスラッシュを使うことで使うことができます:

<!--#if expr="$a = \$test" -->

変数名としてみなされる文字列の中で変数への参照を置換する必要があるときは、 シェルでの変数置換のように、中括弧で括ることで区別することができます:

<!--#set var="Zed" value="${REMOTE_HOST}_${REQUEST_METHOD}" -->

この例では、REMOTE_HOST が "X" で REQUEST_METHOD が "Y" のときに変数 Zed を "X_Y" に設定します。

以下の例では、DOCUMENT_URI/foo/file.html のときに "in foo" を、/bar/file.html のときに "in bar" を、 どちらでもないときには "in neither" を表示します。

<!--#if expr='"$DOCUMENT_URI" = "/foo/file.html"' -->
in foo
<!--#elif expr='"$DOCUMENT_URI" = "/bar/file.html"' -->
in bar
<!--#else -->
in neither
<!--#endif -->

top

フロー制御要素

基本的なフローコントロール要素は次の通りです。

<!--#if expr="test_condition" -->
<!--#elif expr="test_condition" -->
<!--#else -->
<!--#endif -->

if 要素はプログラミング言語の if 文と同じように動作します。条件が評価され、結果が真であれば次の elifelseendif 要素までの文字列が出力に挿入されます。

elifelse 文は test_condition が偽のときにテキストを出力に挿入するために使われます。 これらの要素はあってもなくても構いません。

endif 要素は if 要素を終了させます。この要素は必須です。

test_condition は以下のどれかです:

string
string が空でない場合に真です
string1 = string2
string1 == string2
string1 != string2

string1string2 を比較します。 string2/string/ という形式であれば、正規表現として比較されます。正規表現は PCRE エンジンで実装されていて、 perl 5 と同じ構文を使用します。 == は単に = の別名で、まったく同じ動作を します。

正のマッチング (= または ==) の場合は、 正規表現でグループ分けされたパーツをキャプチャすることができます。 キャプチャされた部分は特殊変数 $1 .. $9 に格納されます。

<!--#if expr="$QUERY_STRING = /^sid=([a-zA-Z0-9]+)/" -->
<!--#set var="session" value="$1" -->
<!--#endif -->

string1 < string2
string1 <= string2
string1 > string2
string1 >= string2
string1string2 を比較します。 文字列として比較される (strcmp(3) を使用) ことに注意してください。ですから、文字列 "100" は "20" よりも小さいことになります。
( test_condition )
test_condition が真のとき、真
! test_condition
test_condition が偽のとき、真
test_condition1 && test_condition2
test_condition1 かつ test_condition2 が真のとき、真
test_condition1 || test_condition2
test_condition1 または test_condition2 が真のとき、真

"=" と "!=" の方が "&&" より きつく束縛します。"!" の束縛が一番きつくなっています。 ですから以下の二つは等価です:

<!--#if expr="$a = test1 && $b = test2" -->
<!--#if expr="($a = test1) && ($b = test2)" -->

真偽値オペレータ &&|| は同じ優先度です。 これらのオペレータで一方により強い優先度をつけたい場合には、 括弧を使う必要があります。

変数やオペレータとして認識されないものはすべて文字列として 扱われます。文字列は引用符で囲むこともできます: 'string' のように。引用符で囲まれていない文字列には空白 (スペースとタブ) を含めることはできません。それらは変数などの句を分離するために 使われているからです。複数の文字列が続いているときは、 空白を間に入れて一つにくっつけられます。ですから、

string1    string2string1 string2 になります。

また、

'string1    string2'string1    string2 になります。

真偽値表現の最適化

式がもっと複雑になり、処理の速度低下が顕著になった場合は、 評価ルールに従って最適化してみると良いでしょう。

  • 評価は左から右に向かって行われます。
  • 二値真偽値オペレータ (&&||) は、出来る限り短絡評価されます。つまり結果として上記のルールは、 mod_include が左の評価式を評価します。 左側で結果を十分決定できる場合は、評価はそこで停止します。 そうでない場合は右側を評価して、左と右の両方から結果を計算します。
  • 短絡評価は評価の対象に正規表現が含まれる場合、オフになります。 後方参照する変数 ($1 .. $9) を埋めるために、実際に評価する必要があるからです。

特定の式がどのように扱われるかを知りたい場合は、 -DDEBUG_INCLUDE コンパイラオプションを付けて mod_include をリコンパイルすると良いでしょう。 これにより、全てのパースされた式に対して、字句解析情報、 パースツリーと、 それがどのようにクライアントに送られた出力まで評価されたかを 挿入します。

top

SSIEndTag ディレクティブ

説明:include 要素を終了させる文字列
構文:SSIEndTag tag
デフォルト:SSIEndTag "-->"
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Base
モジュール:mod_include
互換性:2.0.30 以降で利用可能

このディレクティブは mod_include が探す、 include 要素の終了を示す文字列を変更します。

SSIEndTag "%>"

参照

top

SSIErrorMsg ディレクティブ

説明:SSI のエラーがあったときに表示されるエラーメッセージ
構文:SSIErrorMsg message
デフォルト:SSIErrorMsg "[an error occurred while processing this directive]"
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Base
モジュール:mod_include
互換性:バージョン 2.0.30 以降で使用可能

SSIErrorMsg ディレクティブは mod_include がエラーが起こったときに表示するメッセージを変更します。プロダクションサーバでは メッセージがユーザに表示されないようにするために デフォルトエラーメッセージを "<!-- Error -->" に変えるというようなことを考えるかもしれません。

このディレクティブは <!--#config errmsg=message --> 要素と同じ効果になります。

SSIErrorMsg "<!-- Error -->"

top

SSIStartTag ディレクティブ

説明:include 要素を開始する文字列
構文:SSIStartTag tag
デフォルト:SSIStartTag "<!--#"
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Base
モジュール:mod_include
互換性:バージョン 2.0.30 以降で使用可能

このディレクティブは mod_include が探す、include 要素の開始を示す文字列を変更します。

二つのサーバで (もしかすると別々の段階で) ファイルの出力を解析していて、 それぞれに違うコマンドを処理させたい、 というようなときにこのオプションを使います。

SSIStartTag "<%"
SSIEndTag "%>"

上の例のように対応する SSIEndTag を併せて使うと、 下に示す例のように SSI ディレクティブを使えます:

違う開始と終了のタグを使った SSI ディレクティブ

<%printenv %>

参照

top

SSITimeFormat ディレクティブ

説明:日付けを表す文字列の書式を設定する
構文:SSITimeFormat formatstring
デフォルト:SSITimeFormat "%A, %d-%b-%Y %H:%M:%S %Z"
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Base
モジュール:mod_include
互換性:2.0.30 以降で使用可能

このディレクティブは DATE 環境変数を echo して日付を表す文字列が 表示されるときの書式を変更します。formatstring は C 標準ライブラリの strftime(3) と同じ形式です。

このディレクティブは <!--#config timefmt=formatstring --> 要素と同じ効果になります。

SSITimeFormat "%R, %B %d, %Y"

上のディレクティブでは、日付は "22:26, June 14, 2002" という 形式で表示されます。

top

SSIUndefinedEcho ディレクティブ

説明:未定義の変数が echo されたときに表示される文字列
構文:SSIUndefinedEcho string
デフォルト:SSIUndefinedEcho "(none)"
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:All
ステータス:Base
モジュール:mod_include
互換性:2.0.34 以降で利用可能

このディレクティブは変数が定義されていないにも関わらず "echo" されたときに mod_include が表示する文字列を変更します。

SSIUndefinedEcho "<!-- undef -->"

top

XBitHack ディレクティブ

説明:実行ビットが設定されたファイルの SSI ディレクティブを 解析する
構文:XBitHack on|off|full
デフォルト:XBitHack off
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:Options
ステータス:Base
モジュール:mod_include

XBitHack ディレクティブは通常の HTML ドキュメントの解析を制御します。このディレクティブは MIME タイプ text/html と関連付けられているファイルにのみ影響します。 XBitHack は以下の値をとることができます。

off
実行可能ファイルに対して特別な扱いをしません。
on
ユーザの実行ビットが設定されている text/html ファイルは全てサーバで解析する html ドキュメントとして扱われます。
full
on と同様ですが、グループ実行ビットもテストします。 もしそれが設定されていれば、返されるファイルの Last-modified の 日付をファイルの最終修正時刻にします。それが設定されていないときは、 last-modified の日付は送られません。このビットを設定すると、 クライアントやプロキシがリクエストをキャッシュできるようになります。
注意 他の CGI を #include するかもしれないものや、各アクセスに対して違う出力を生成する (もしくは後のリクエストで変わるかもしれないもの) すべての SSI スクリプトに対してグループ実行ビットが 設定されていないことを確認できない場合は、full は使わない方が良い でしょう。
mod/mod_info.html100644 0 0 26317 11237400230 11465 0ustar 0 0 mod_info - Apache HTTP サーバ
<-

Apache モジュール mod_info

This translation may be out of date. Check the English version for recent changes.
説明:サーバの設定の包括的な概観を提供する
ステータス:Extension
モジュール識別子:info_module
ソースファイル:mod_info.c

概要

mod_info を設定するには、以下を httpd.conf ファイルに加えます。

<Location /server-info>
SetHandler server-info
</Location>

<Location> の中で mod_access を使って、サーバ設定情報への アクセスを制限したいと思うかもしれません :

<Location /server-info>
SetHandler server-info
Order deny,allow
Deny from all
Allow from yourcompany.com
</Location>

一旦設定すると、http://your.host.example.com/server-info にアクセスすることでサーバの情報を得られるようになります。

top

Security Issues

一旦 mod_info がサーバに読み込まれると、 提供しているハンドラ機能はディレクトリ毎の設定ファイル (例えば .htaccess) を含む すべての設定ファイルで有効になります。 このモジュールを有効にするときはセキュリティの問題を考慮する必要が あるでしょう。

特に、このモジュールはシステムパス、ユーザ名/パスワード、 データベース名など、他の Apache モジュールの設定ディレクティブから セキュリティ上微妙な情報を漏らす可能性があります。 ですから、このモジュールはきちんとアクセス制御された環境でのみ、 注意して使ってください。

設定情報へのアクセスを制限するために、mod_authz_host を 使うのが良いでしょう。

アクセス制御

<Location /server-info>
SetHandler server-info
Order allow,deny
# Allow access from server itself
Allow from 127.0.0.1
# Additionally, allow access from local workstation
Allow from 192.168.1.17
</Location>

top

表示される情報の選択

デフォルトでは、サーバ情報はすべての有効なモジュールと、 各モジュールについて、モジュールが理解するディレクティブ、 実装している、フック、現時点での設定の関連するディレクティブに なっています。

server-info リクエストへクエリーを追加することで、 設定情報の他の表示形式を選ぶことができます。例えば、 http://your.host.example.com/server-info?config は すべての設定ディレクティブを表示します。

?<module-name>
指定されたモジュールに関連する情報のみ
?config
モジュールでソートせずに、設定ディレクティブのみ
?hooks
各モジュールが使用するフックのみ
?list
有効なモジュールの簡単なリストのみ
?server
基本サーバ情報のみ
top

既知の制限

mod_info は、元の設定ファイルを読むのではなく、 既にパースされた設定を読み込むことで情報を提供します。従って、 パース済みの設定情報の木が生成される方法による制限がいくつかあります:

  • パースされた設定に保存されずに、すぐに実行されるディレクティブは 一覧に現れません。これには ServerRoot, LoadModule, LoadFile があります。
  • Include, <IfModule>, <IfDefine>, のような設定ファイル自身を制御するディレクティブは表示されません。 そのディレクティブの中にあり、有効になっているディレクティブは 表示されます。
  • コメントは表示されません。(これは仕様だと思ってください。)
  • .htaccess ファイルの設定ディレクティブは表示されません (永久的なサーバ設定の一部ではないからです)。
  • <Directory> のようなコンテナディレクティブは普通に表示されますが、 mod_info は閉じタグの </Directory> などの数を知ることはできません。
  • mod_perl のようなサードパーティモジュール のディレクティブは表示されないかもしれません。
top

AddModuleInfo ディレクティブ

説明:server-info ハンドラにより表示されるモジュールの情報に 追加の情報を付け加える
構文:AddModuleInfo module-name string
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_info
互換性:Apache 1.3 以降

これは、string の内容がモジュール module-name追加情報 として HTML として解釈され、表示されるようにします。例:

AddModuleInfo mod_deflate.c 'See <a \
href="http://www.apache.org/docs/2.2/mod/mod_deflate.html">\
http://www.apache.org/docs/2.2/mod/mod_deflate.html</a>'

mod/mod_isapi.html100644 0 0 47633 11237400230 11643 0ustar 0 0 mod_isapi - Apache HTTP Server
<-

Apache Module mod_isapi

Description:ISAPI Extensions within Apache for Windows
Status:Base
ModuleIdentifier:isapi_module
SourceFile:mod_isapi.c
Compatibility:Win32 only

Summary

This module implements the Internet Server extension API. It allows Internet Server extensions (e.g. ISAPI .dll modules) to be served by Apache for Windows, subject to the noted restrictions.

ISAPI extension modules (.dll files) are written by third parties. The Apache Group does not author these modules, so we provide no support for them. Please contact the ISAPI's author directly if you are experiencing problems running their ISAPI extension. Please do not post such problems to Apache's lists or bug reporting pages.

top

Usage

In the server configuration file, use the AddHandler directive to associate ISAPI files with the isapi-handler handler, and map it to them with their file extensions. To enable any .dll file to be processed as an ISAPI extension, edit the httpd.conf file and add the following line:

AddHandler isapi-handler .dll

In older versions of the Apache server, isapi-isa was the proper handler name, rather than isapi-handler. For compatibility, configurations may continue using isapi-isa through all versions of Apache prior to 2.3.0.

There is no capability within the Apache server to leave a requested module loaded. However, you may preload and keep a specific module loaded by using the following syntax in your httpd.conf:

ISAPICacheFile c:/WebWork/Scripts/ISAPI/mytest.dll

Whether or not you have preloaded an ISAPI extension, all ISAPI extensions are governed by the same permissions and restrictions as CGI scripts. That is, Options ExecCGI must be set for the directory that contains the ISAPI .dll file.

Review the Additional Notes and the Programmer's Journal for additional details and clarification of the specific ISAPI support offered by mod_isapi.

top

Additional Notes

Apache's ISAPI implementation conforms to all of the ISAPI 2.0 specification, except for some "Microsoft-specific" extensions dealing with asynchronous I/O. Apache's I/O model does not allow asynchronous reading and writing in a manner that the ISAPI could access. If an ISA tries to access unsupported features, including async I/O, a message is placed in the error log to help with debugging. Since these messages can become a flood, the directive ISAPILogNotSupported Off exists to quiet this noise.

Some servers, like Microsoft IIS, load the ISAPI extension into the server and keep it loaded until memory usage is too high, or unless configuration options are specified. Apache currently loads and unloads the ISAPI extension each time it is requested, unless the ISAPICacheFile directive is specified. This is inefficient, but Apache's memory model makes this the most effective method. Many ISAPI modules are subtly incompatible with the Apache server, and unloading these modules helps to ensure the stability of the server.

Also, remember that while Apache supports ISAPI Extensions, it does not support ISAPI Filters. Support for filters may be added at a later date, but no support is planned at this time.

top

Programmer's Journal

If you are programming Apache 2.0 mod_isapi modules, you must limit your calls to ServerSupportFunction to the following directives:

HSE_REQ_SEND_URL_REDIRECT_RESP
Redirect the user to another location.
This must be a fully qualified URL (e.g. http://server/location).
HSE_REQ_SEND_URL
Redirect the user to another location.
This cannot be a fully qualified URL, you are not allowed to pass the protocol or a server name (e.g. simply /location).
This redirection is handled by the server, not the browser.

Warning

In their recent documentation, Microsoft appears to have abandoned the distinction between the two HSE_REQ_SEND_URL functions. Apache continues to treat them as two distinct functions with different requirements and behaviors.

HSE_REQ_SEND_RESPONSE_HEADER
Apache accepts a response body following the header if it follows the blank line (two consecutive newlines) in the headers string argument. This body cannot contain NULLs, since the headers argument is NULL terminated.
HSE_REQ_DONE_WITH_SESSION
Apache considers this a no-op, since the session will be finished when the ISAPI returns from processing.
HSE_REQ_MAP_URL_TO_PATH
Apache will translate a virtual name to a physical name.
HSE_APPEND_LOG_PARAMETER
This logged message may be captured in any of the following logs:

The first option, the %{isapi-parameter}n component, is always available and preferred.

HSE_REQ_IS_KEEP_CONN
Will return the negotiated Keep-Alive status.
HSE_REQ_SEND_RESPONSE_HEADER_EX
Will behave as documented, although the fKeepConn flag is ignored.
HSE_REQ_IS_CONNECTED
Will report false if the request has been aborted.

Apache returns FALSE to any unsupported call to ServerSupportFunction, and sets the GetLastError value to ERROR_INVALID_PARAMETER.

ReadClient retrieves the request body exceeding the initial buffer (defined by ISAPIReadAheadBuffer). Based on the ISAPIReadAheadBuffer setting (number of bytes to buffer prior to calling the ISAPI handler) shorter requests are sent complete to the extension when it is invoked. If the request is longer, the ISAPI extension must use ReadClient to retrieve the remaining request body.

WriteClient is supported, but only with the HSE_IO_SYNC flag or no option flag (value of 0). Any other WriteClient request will be rejected with a return value of FALSE, and a GetLastError value of ERROR_INVALID_PARAMETER.

GetServerVariable is supported, although extended server variables do not exist (as defined by other servers.) All the usual Apache CGI environment variables are available from GetServerVariable, as well as the ALL_HTTP and ALL_RAW values.

Apache 2.0 mod_isapi supports additional features introduced in later versions of the ISAPI specification, as well as limited emulation of async I/O and the TransmitFile semantics. Apache also supports preloading ISAPI .dlls for performance, neither of which were not available under Apache 1.3 mod_isapi.

top

ISAPIAppendLogToErrors Directive

Description:Record HSE_APPEND_LOG_PARAMETER requests from ISAPI extensions to the error log
Syntax:ISAPIAppendLogToErrors on|off
Default:ISAPIAppendLogToErrors off
Context:server config, virtual host, directory, .htaccess
Override:FileInfo
Status:Base
Module:mod_isapi

Record HSE_APPEND_LOG_PARAMETER requests from ISAPI extensions to the server error log.

top

ISAPIAppendLogToQuery Directive

Description:Record HSE_APPEND_LOG_PARAMETER requests from ISAPI extensions to the query field
Syntax:ISAPIAppendLogToQuery on|off
Default:ISAPIAppendLogToQuery on
Context:server config, virtual host, directory, .htaccess
Override:FileInfo
Status:Base
Module:mod_isapi

Record HSE_APPEND_LOG_PARAMETER requests from ISAPI extensions to the query field (appended to the CustomLog %q component).

top

ISAPICacheFile Directive

Description:ISAPI .dll files to be loaded at startup
Syntax:ISAPICacheFile file-path [file-path] ...
Context:server config, virtual host
Status:Base
Module:mod_isapi

Specifies a space-separated list of file names to be loaded when the Apache server is launched, and remain loaded until the server is shut down. This directive may be repeated for every ISAPI .dll file desired. The full path name of each file should be specified. If the path name is not absolute, it will be treated relative to ServerRoot.

top

ISAPIFakeAsync Directive

Description:Fake asynchronous support for ISAPI callbacks
Syntax:ISAPIFakeAsync on|off
Default:ISAPIFakeAsync off
Context:server config, virtual host, directory, .htaccess
Override:FileInfo
Status:Base
Module:mod_isapi

While set to on, asynchronous support for ISAPI callbacks is simulated.

top

ISAPILogNotSupported Directive

Description:Log unsupported feature requests from ISAPI extensions
Syntax:ISAPILogNotSupported on|off
Default:ISAPILogNotSupported off
Context:server config, virtual host, directory, .htaccess
Override:FileInfo
Status:Base
Module:mod_isapi

Logs all requests for unsupported features from ISAPI extensions in the server error log. This may help administrators to track down problems. Once set to on and all desired ISAPI modules are functioning, it should be set back to off.

top

ISAPIReadAheadBuffer Directive

Description:Size of the Read Ahead Buffer sent to ISAPI extensions
Syntax:ISAPIReadAheadBuffer size
Default:ISAPIReadAheadBuffer 49152
Context:server config, virtual host, directory, .htaccess
Override:FileInfo
Status:Base
Module:mod_isapi

Defines the maximum size of the Read Ahead Buffer sent to ISAPI extensions when they are initially invoked. All remaining data must be retrieved using the ReadClient callback; some ISAPI extensions may not support the ReadClient function. Refer questions to the ISAPI extension's author.

mod/mod_ldap.html100644 0 0 107131 11237400230 11464 0ustar 0 0 mod_ldap - Apache HTTP Server
<-

Apache Module mod_ldap

Description:LDAP connection pooling and result caching services for use by other LDAP modules
Status:Extension
ModuleIdentifier:ldap_module
SourceFile:util_ldap.c
Compatibility:Available in version 2.0.41 and later

Summary

This module was created to improve the performance of websites relying on backend connections to LDAP servers. In addition to the functions provided by the standard LDAP libraries, this module adds an LDAP connection pool and an LDAP shared memory cache.

To enable this module, LDAP support must be compiled into apr-util. This is achieved by adding the --with-ldap flag to the configure script when building Apache.

SSL/TLS support is dependant on which LDAP toolkit has been linked to APR. As of this writing, APR-util supports: OpenLDAP SDK (2.x or later), Novell LDAP SDK, Mozilla LDAP SDK, native Solaris LDAP SDK (Mozilla based), native Microsoft LDAP SDK, or the iPlanet (Netscape) SDK. See the APR website for details.

top

Example Configuration

The following is an example configuration that uses mod_ldap to increase the performance of HTTP Basic authentication provided by mod_authnz_ldap.

# Enable the LDAP connection pool and shared
# memory cache. Enable the LDAP cache status
# handler. Requires that mod_ldap and mod_authnz_ldap
# be loaded. Change the "yourdomain.example.com" to
# match your domain.

LDAPSharedCacheSize 200000
LDAPCacheEntries 1024
LDAPCacheTTL 600
LDAPOpCacheEntries 1024
LDAPOpCacheTTL 600

<Location /ldap-status>
SetHandler ldap-status
Order deny,allow
Deny from all
Allow from yourdomain.example.com
AuthLDAPURL ldap://127.0.0.1/dc=example,dc=com?uid?one
AuthzLDAPAuthoritative off
Require valid-user
</Location>

top

LDAP Connection Pool

LDAP connections are pooled from request to request. This allows the LDAP server to remain connected and bound ready for the next request, without the need to unbind/connect/rebind. The performance advantages are similar to the effect of HTTP keepalives.

On a busy server it is possible that many requests will try and access the same LDAP server connection simultaneously. Where an LDAP connection is in use, Apache will create a new connection alongside the original one. This ensures that the connection pool does not become a bottleneck.

There is no need to manually enable connection pooling in the Apache configuration. Any module using this module for access to LDAP services will share the connection pool.

top

LDAP Cache

For improved performance, mod_ldap uses an aggressive caching strategy to minimize the number of times that the LDAP server must be contacted. Caching can easily double or triple the throughput of Apache when it is serving pages protected with mod_authnz_ldap. In addition, the load on the LDAP server will be significantly decreased.

mod_ldap supports two types of LDAP caching during the search/bind phase with a search/bind cache and during the compare phase with two operation caches. Each LDAP URL that is used by the server has its own set of these three caches.

The Search/Bind Cache

The process of doing a search and then a bind is the most time-consuming aspect of LDAP operation, especially if the directory is large. The search/bind cache is used to cache all searches that resulted in successful binds. Negative results (i.e., unsuccessful searches, or searches that did not result in a successful bind) are not cached. The rationale behind this decision is that connections with invalid credentials are only a tiny percentage of the total number of connections, so by not caching invalid credentials, the size of the cache is reduced.

mod_ldap stores the username, the DN retrieved, the password used to bind, and the time of the bind in the cache. Whenever a new connection is initiated with the same username, mod_ldap compares the password of the new connection with the password in the cache. If the passwords match, and if the cached entry is not too old, mod_ldap bypasses the search/bind phase.

The search and bind cache is controlled with the LDAPCacheEntries and LDAPCacheTTL directives.

Operation Caches

During attribute and distinguished name comparison functions, mod_ldap uses two operation caches to cache the compare operations. The first compare cache is used to cache the results of compares done to test for LDAP group membership. The second compare cache is used to cache the results of comparisons done between distinguished names.

The behavior of both of these caches is controlled with the LDAPOpCacheEntries and LDAPOpCacheTTL directives.

Monitoring the Cache

mod_ldap has a content handler that allows administrators to monitor the cache performance. The name of the content handler is ldap-status, so the following directives could be used to access the mod_ldap cache information:

<Location /server/cache-info>
SetHandler ldap-status
</Location>

By fetching the URL http://servername/cache-info, the administrator can get a status report of every cache that is used by mod_ldap cache. Note that if Apache does not support shared memory, then each httpd instance has its own cache, so reloading the URL will result in different information each time, depending on which httpd instance processes the request.

top

Using SSL/TLS

The ability to create an SSL and TLS connections to an LDAP server is defined by the directives LDAPTrustedGlobalCert, LDAPTrustedClientCert and LDAPTrustedMode. These directives specify the CA and optional client certificates to be used, as well as the type of encryption to be used on the connection (none, SSL or TLS/STARTTLS).

# Establish an SSL LDAP connection on port 636. Requires that
# mod_ldap and mod_authnz_ldap be loaded. Change the
# "yourdomain.example.com" to match your domain.

LDAPTrustedGlobalCert CA_DER /certs/certfile.der

<Location /ldap-status>
SetHandler ldap-status
Order deny,allow
Deny from all
Allow from yourdomain.example.com
AuthLDAPURL ldaps://127.0.0.1/dc=example,dc=com?uid?one
AuthzLDAPAuthoritative off
Require valid-user
</Location>

# Establish a TLS LDAP connection on port 389. Requires that
# mod_ldap and mod_authnz_ldap be loaded. Change the
# "yourdomain.example.com" to match your domain.

LDAPTrustedGlobalCert CA_DER /certs/certfile.der

<Location /ldap-status>
SetHandler ldap-status
Order deny,allow
Deny from all
Allow from yourdomain.example.com
AuthLDAPURL ldap://127.0.0.1/dc=example,dc=com?uid?one TLS
AuthzLDAPAuthoritative off
Require valid-user
</Location>

top

SSL/TLS Certificates

The different LDAP SDKs have widely different methods of setting and handling both CA and client side certificates.

If you intend to use SSL or TLS, read this section CAREFULLY so as to understand the differences between configurations on the different LDAP toolkits supported.

Netscape/Mozilla/iPlanet SDK

CA certificates are specified within a file called cert7.db. The SDK will not talk to any LDAP server whose certificate was not signed by a CA specified in this file. If client certificates are required, an optional key3.db file may be specified with an optional password. The secmod file can be specified if required. These files are in the same format as used by the Netscape Communicator or Mozilla web browsers. The easiest way to obtain these files is to grab them from your browser installation.

Client certificates are specified per connection using the LDAPTrustedClientCert directive by referring to the certificate "nickname". An optional password may be specified to unlock the certificate's private key.

The SDK supports SSL only. An attempt to use STARTTLS will cause an error when an attempt is made to contact the LDAP server at runtime.

# Specify a Netscape CA certificate file
LDAPTrustedGlobalCert CA_CERT7_DB /certs/cert7.db
# Specify an optional key3.db file for client certificate support
LDAPTrustedGlobalCert CERT_KEY3_DB /certs/key3.db
# Specify the secmod file if required
LDAPTrustedGlobalCert CA_SECMOD /certs/secmod
<Location /ldap-status>
SetHandler ldap-status
Order deny,allow
Deny from all
Allow from yourdomain.example.com
LDAPTrustedClientCert CERT_NICKNAME <nickname> [password]
AuthLDAPURL ldaps://127.0.0.1/dc=example,dc=com?uid?one
AuthzLDAPAuthoritative off
Require valid-user
</Location>

Novell SDK

One or more CA certificates must be specified for the Novell SDK to work correctly. These certificates can be specified as binary DER or Base64 (PEM) encoded files.

Note: Client certificates are specified globally rather than per connection, and so must be specified with the LDAPTrustedGlobalCert directive as below. Trying to set client certificates via the LDAPTrustedClientCert directive will cause an error to be logged when an attempt is made to connect to the LDAP server..

The SDK supports both SSL and STARTTLS, set using the LDAPTrustedMode parameter. If an ldaps:// URL is specified, SSL mode is forced, override this directive.

# Specify two CA certificate files
LDAPTrustedGlobalCert CA_DER /certs/cacert1.der
LDAPTrustedGlobalCert CA_BASE64 /certs/cacert2.pem
# Specify a client certificate file and key
LDAPTrustedGlobalCert CERT_BASE64 /certs/cert1.pem
LDAPTrustedGlobalCert KEY_BASE64 /certs/key1.pem [password]
# Do not use this directive, as it will throw an error
#LDAPTrustedClientCert CERT_BASE64 /certs/cert1.pem

OpenLDAP SDK

One or more CA certificates must be specified for the OpenLDAP SDK to work correctly. These certificates can be specified as binary DER or Base64 (PEM) encoded files.

Client certificates are specified per connection using the LDAPTrustedClientCert directive.

The documentation for the SDK claims to support both SSL and STARTTLS, however STARTTLS does not seem to work on all versions of the SDK. The SSL/TLS mode can be set using the LDAPTrustedMode parameter. If an ldaps:// URL is specified, SSL mode is forced. The OpenLDAP documentation notes that SSL (ldaps://) support has been deprecated to be replaced with TLS, although the SSL functionality still works.

# Specify two CA certificate files
LDAPTrustedGlobalCert CA_DER /certs/cacert1.der
LDAPTrustedGlobalCert CA_BASE64 /certs/cacert2.pem
<Location /ldap-status>
SetHandler ldap-status
Order deny,allow
Deny from all
Allow from yourdomain.example.com
LDAPTrustedClientCert CERT_BASE64 /certs/cert1.pem
LDAPTrustedClientCert KEY_BASE64 /certs/key1.pem
AuthLDAPURL ldaps://127.0.0.1/dc=example,dc=com?uid?one
AuthzLDAPAuthoritative off
Require valid-user
</Location>

Solaris SDK

SSL/TLS for the native Solaris LDAP libraries is not yet supported. If required, install and use the OpenLDAP libraries instead.

Microsoft SDK

SSL/TLS certificate configuration for the native Microsoft LDAP libraries is done inside the system registry, and no configuration directives are required.

Both SSL and TLS are supported by using the ldaps:// URL format, or by using the LDAPTrustedMode directive accordingly.

Note: The status of support for client certificates is not yet known for this toolkit.

top

LDAPCacheEntries Directive

Description:Maximum number of entries in the primary LDAP cache
Syntax:LDAPCacheEntries number
Default:LDAPCacheEntries 1024
Context:server config
Status:Extension
Module:mod_ldap

Specifies the maximum size of the primary LDAP cache. This cache contains successful search/binds. Set it to 0 to turn off search/bind caching. The default size is 1024 cached searches.

top

LDAPCacheTTL Directive

Description:Time that cached items remain valid
Syntax:LDAPCacheTTL seconds
Default:LDAPCacheTTL 600
Context:server config
Status:Extension
Module:mod_ldap

Specifies the time (in seconds) that an item in the search/bind cache remains valid. The default is 600 seconds (10 minutes).

top

LDAPConnectionTimeout Directive

Description:Specifies the socket connection timeout in seconds
Syntax:LDAPConnectionTimeout seconds
Context:server config
Status:Extension
Module:mod_ldap

Specifies the timeout value (in seconds) in which the module will attempt to connect to the LDAP server. If a connection is not successful with the timeout period, either an error will be returned or the module will attempt to connect to a secondary LDAP server if one is specified. The default is 10 seconds.

top

LDAPOpCacheEntries Directive

Description:Number of entries used to cache LDAP compare operations
Syntax:LDAPOpCacheEntries number
Default:LDAPOpCacheEntries 1024
Context:server config
Status:Extension
Module:mod_ldap

This specifies the number of entries mod_ldap will use to cache LDAP compare operations. The default is 1024 entries. Setting it to 0 disables operation caching.

top

LDAPOpCacheTTL Directive

Description:Time that entries in the operation cache remain valid
Syntax:LDAPOpCacheTTL seconds
Default:LDAPOpCacheTTL 600
Context:server config
Status:Extension
Module:mod_ldap

Specifies the time (in seconds) that entries in the operation cache remain valid. The default is 600 seconds.

top

LDAPSharedCacheFile Directive

Description:Sets the shared memory cache file
Syntax:LDAPSharedCacheFile directory-path/filename
Context:server config
Status:Extension
Module:mod_ldap

Specifies the directory path and file name of the shared memory cache file. If not set, anonymous shared memory will be used if the platform supports it.

top

LDAPSharedCacheSize Directive

Description:Size in bytes of the shared-memory cache
Syntax:LDAPSharedCacheSize bytes
Default:LDAPSharedCacheSize 102400
Context:server config
Status:Extension
Module:mod_ldap

Specifies the number of bytes to allocate for the shared memory cache. The default is 100kb. If set to 0, shared memory caching will not be used.

top

LDAPTrustedClientCert Directive

Description:Sets the file containing or nickname referring to a per connection client certificate. Not all LDAP toolkits support per connection client certificates.
Syntax:LDAPTrustedClientCert type directory-path/filename/nickname [password]
Context:server config, virtual host, directory, .htaccess
Status:Extension
Module:mod_ldap

It specifies the directory path, file name or nickname of a per connection client certificate used when establishing an SSL or TLS connection to an LDAP server. Different locations or directories may have their own independant client certificate settings. Some LDAP toolkits (notably Novell) do not support per connection client certificates, and will throw an error on LDAP server connection if you try to use this directive (Use the LDAPTrustedGlobalCert directive instead for Novell client certificates - See the SSL/TLS certificate guide above for details). The type specifies the kind of certificate parameter being set, depending on the LDAP toolkit being used. Supported types are:

  • CERT_DER - binary DER encoded client certificate
  • CERT_BASE64 - PEM encoded client certificate
  • CERT_NICKNAME - Client certificate "nickname" (Netscape SDK)
  • KEY_DER - binary DER encoded private key
  • KEY_BASE64 - PEM encoded private key
top

LDAPTrustedGlobalCert Directive

Description:Sets the file or database containing global trusted Certificate Authority or global client certificates
Syntax:LDAPTrustedGlobalCert type directory-path/filename [password]
Context:server config
Status:Extension
Module:mod_ldap

It specifies the directory path and file name of the trusted CA certificates and/or system wide client certificates mod_ldap should use when establishing an SSL or TLS connection to an LDAP server. Note that all certificate information specified using this directive is applied globally to the entire server installation. Some LDAP toolkits (notably Novell) require all client certificates to be set globally using this directive. Most other toolkits require clients certificates to be set per Directory or per Location using LDAPTrustedClientCert. If you get this wrong, an error may be logged when an attempt is made to contact the LDAP server, or the connection may silently fail (See the SSL/TLS certificate guide above for details). The type specifies the kind of certificate parameter being set, depending on the LDAP toolkit being used. Supported types are:

  • CA_DER - binary DER encoded CA certificate
  • CA_BASE64 - PEM encoded CA certificate
  • CA_CERT7_DB - Netscape cert7.db CA certificate database file
  • CA_SECMOD - Netscape secmod database file
  • CERT_DER - binary DER encoded client certificate
  • CERT_BASE64 - PEM encoded client certificate
  • CERT_KEY3_DB - Netscape key3.db client certificate database file
  • CERT_NICKNAME - Client certificate "nickname" (Netscape SDK)
  • CERT_PFX - PKCS#12 encoded client certificate (Novell SDK)
  • KEY_DER - binary DER encoded private key
  • KEY_BASE64 - PEM encoded private key
  • KEY_PFX - PKCS#12 encoded private key (Novell SDK)
top

LDAPTrustedMode Directive

Description:Specifies the SSL/TLS mode to be used when connecting to an LDAP server.
Syntax:LDAPTrustedMode type
Context:server config, virtual host
Status:Extension
Module:mod_ldap

The following modes are supported:

  • NONE - no encryption
  • SSL - ldaps:// encryption on default port 636
  • TLS - STARTTLS encryption on default port 389

Not all LDAP toolkits support all the above modes. An error message will be logged at runtime if a mode is not supported, and the connection to the LDAP server will fail.

If an ldaps:// URL is specified, the mode becomes SSL and the setting of LDAPTrustedMode is ignored.

top

LDAPVerifyServerCert Directive

Description:Force server certificate verification
Syntax:LDAPVerifyServerCert On|Off
Default:LDAPVerifyServerCert On
Context:server config
Status:Extension
Module:mod_ldap

Specifies whether to force the verification of a server certificate when establishing an SSL connection to the LDAP server.

mod/mod_log_config.html100644 0 0 72643 11237400230 12643 0ustar 0 0 mod_log_config - Apache HTTP サーバ
<-

Apache モジュール mod_log_config

This translation may be out of date. Check the English version for recent changes.
説明:サーバへのリクエストのロギング
ステータス:Base
モジュール識別子:log_config_module
ソースファイル:mod_log_config.c

概要

このモジュールはクライアントのリクエストを柔軟にログ収集する機能を 提供します。ログはカスタマイズ可能な書式で書かれ、ファイルに直接 書いたり、外部プログラムに渡したりすることができます。個々のリクエストを 特徴に応じてログに書いたり書かなかったりできるように、条件による ログ収集も提供されています。

このモジュールは三つのディレクティブ提供します: ログファイルを作成するための TransferLog, 新しい書式を 定義する LogFormat, ログファイルと 書式を一度に定義する CustomLog です。 各リクエストが複数回ログ収集されるようにするために TransferLog ディレクティブと CustomLog ディレクティブは複数回使用することができます。

top

カスタムログ書式

LogFormat ディレクティブと CustomLog ディレクティブの書式を指定する引数は文字列です。この文字列を使ってそれぞれの リクエストがログファイルにログ収集されます。その文字列には ログファイルにそのまま 書かれる文字列や、それぞれ改行とタブを表す C 言語 形式の制御文字 "\n" と "\t" とを含めることができます。そのまま出力させたい引用符とバックスラッシュは バックスラッシュでエスケープする必要があります。

リクエストの特徴そのものは "%" ディレクティブを書式の文字列に書くことで ログ収集されます。"%" ディレクティブはログファイル中では以下のような 値で置換されます:

フォーマット文字列 説明
%% パーセント記号
%a リモート IP アドレス
%A ローカル IP アドレス
%B レスポンスのバイト数。HTTP ヘッダは除く。
%b レスポンスのバイト数。HTTP ヘッダは除く。CLF 書式。 すなわち、1 バイトも送られなかったときは 0 ではなく、 '-' になる
%{Foobar}C サーバに送られたリクエスト中のクッキー Foobar の値
%D リクエストを処理するのにかかった時間、マイクロ秒単位
%{FOOBAR}e 環境変数 FOOBAR の内容
%f ファイル名
%h リモートホスト
%H リクエストプロトコル
%{Foobar}i サーバに送られたリクエストの Foobar: ヘッダの内容
%l (identd からもし提供されていれば) リモートログ名。 これは mod_ident がサーバに存在して、 IdentityCheck ディレクティブが On に設定されていない限り、 - になります。
%m リクエストメソッド
%{Foobar}n 他のモジュールからのメモ Foobar の内容
%{Foobar}o 応答の Foobar: ヘッダの内容
%p リクエストを扱っているサーバの正式なポート
%P リクエストを扱った子プロセスのプロセス ID
%{format}P リクエストを扱ったワーカーのプロセス ID かスレッド ID。 format として有効な値は pid, tid, hextid です。hextid を使うには APR 1.2.0 以降が必要です。
%q 問い合せ文字列 (存在する場合は前に ? が追加される。 そうでない場合は空文字列)
%r リクエストの最初の行
%s ステータス。内部でリダイレクトされたリクエストは、元々の リクエストのステータス --- 最後のステータスは %>s
%t リクエストを受付けた時刻。 CLF の時刻の書式 (標準の英語の書式)
%{format}t format で与えられた書式による時刻。format は strftime (3) の 書式である必要がある。(地域化されている可能性がある)
%T リクエストを扱うのにかかった時間、秒単位
%u リモートユーザ (認証によるもの。ステータス (%s) が 401 のときは意味がないものである可能性がある)
%U リクエストされた URL パス。クエリ文字列は含まない
%v リクエストを扱っているサーバの正式な ServerName
%V UseCanonicalName の設定によるサーバ名
%X 応答が完了したときの接続ステータス:
X = 応答が完了する前に接続が異常終了
+ = 応答が送られた後に接続を持続することが可能
- = 応答が送られた後に接続が切られる

(このディレクティブは Apache 1.3 の後期のバージョンでは %c に割り当てられて いましたが、これは歴史的に ssl が使用している %{var}c 構文と衝突していました。)

%I リクエストとヘッダを含む、受け取ったバイト数。 0 にはならない。 これを使用するためには mod_logio が必要
%O ヘッダを含む、送信したバイト数。0 にはならない。 これを使用するためには mod_logio が必要

修飾子

特定の要素は "%" の直後に HTTP ステータスコードをカンマ区切りで 指定することで、表示を制限することができます。例えば "%400,501{User-agent}i" では、 400 と 500 番エラーでのみ User-agent をログします。 他のステータスコードでは "-" という文字列が ログされます。ステータスコードのリストは "!" で否定を指定することができます : "%!200,304,302{Referer}i" は、指定された 3 つのコードのどれにも該当しないリクエスト全てで Referer をログします。

修飾子 "<" と ">" は内部リダイレクトされたリクエストのログに 元のリクエストか最終的なリクエストのどちらを使用するかを 指定するために使います。デフォルトでは、% ディレクティブの %s, %U, %T, %D, %r は元のリクエストを、他は最終的なリクエストを 使用します。例えば、リクエストの最終ステータスを記録するには %>s を、内部的に認証されていないリソースへリダイレクトされた リクエストで元のリクエストで認証されたユーザを記録するためには %<u を使うことができます。

その他注意点

セキュリティ上の理由により 2.0.46 より、 %r, %i, %o に入っている、 印字不可能な文字と他の特別な文字は、\xhh という形式の文字列でエスケープされるようになりました。hh は そのままのバイトの値の 16 進での値です。この規則の例外には、 バックスラッシュを使ってエスケープされる "\ と、 C 形式の表記法が使われる空白文字 (\n, \t など) があります。2.0.46 以前のバージョンではエスケープ処理は行われませんので、 生ログファイルを扱う際に注意が必要です。

httpd 2.0 では 1.3 とは異なり、%b%B フォーマット文字列はクライアントに送信されたバイト数そのものではなく、 HTTP レスポンスのバイト数です (これらは異なるもので、たとえば、 コネクションが途中で破棄された場合や、SSL 使用時に一致しません) 。 mod_logio で提供されている %O フォーマット文字列で、ネットワーク経由で実際に転送されたバイト数を 記録できます。

よく使われるフォーマット文字列は:

Common Log Format (CLF)
"%h %l %u %t \"%r\" %>s %b"
バーチャルホスト付き Common Log Format
"%v %h %l %u %t \"%r\" %>s %b"
NCSA extended/combined ログ書式
"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
Referer ログ書式
"%{Referer}i -> %U"
Agent (ブラウザ) ログ書式
"%{User-agent}i"
top

セキュリティに関して

ログファイルが保存されているディレクトリがサーバを起動した以外のユーザで 書き込み可能なときにセキュリティの問題が発生する理由の詳細はセキュリティのこつ を参照してください。

top

BufferedLogs ディレクティブ

説明:ディスクに書き出す前にメモリにログエントリをバッファする
構文:BufferedLogs On|Off
デフォルト:BufferedLogs Off
コンテキスト:サーバ設定ファイル
ステータス:Base
モジュール:mod_log_config
互換性:2.0.41 以降

BufferedLogs ディレクティブを使うと mod_log_config の挙動が変化して、 複数のログを書き出す際に、それぞれのリクエスト処理後毎に 書き出すのではなく、いったんメモリに蓄えてから、 まとめてディスクに書き出すようになります。 この結果ディスクアクセスがより効率的になり、 高いパフォーマンスの得られるシステムもあるでしょう。 このディレクティブはサーバ全体で一度だけ設定できます; バーチャルホストごとに設定することはできません。

このディレクティブは実験的なものですので、 使用する際は注意してください。
top

CookieLog ディレクティブ

説明:クッキングのロギングのためのファイル名を設定する
構文:CookieLog filename
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Base
モジュール:mod_log_config
互換性:このディレクティブは非推奨

CookieLog ディレクティブはクッキーのロギングのためのファイル名を 設定します。filename は ServerRoot からの相対パスです。このディレクティブは mod_cookies との互換性のためだけに 存在し、使用は推奨されていません。

top

CustomLog ディレクティブ

説明:ログファイルの名前と書式を設定する
構文:CustomLog file|pipe format|nickname [env=[!]environment-variable]
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Base
モジュール:mod_log_config

CustomLog ディレクティブはサーバへのリクエストを ログ収集するために使われます。ログの書式が指定され、 環境変数を使ってロギングが条件に応じて行なわれるようにすることもできます。

ログが書かれる場所を指定する最初の引数は以下の二つの形式の値を とることができます:

file
ServerRoot からの相対パスで表されるファイル名。
pipe
パイプ文字 "|" と、その後に標準入力からログの 情報を受けとるプログラムへのパスが続いたもの。

セキュリティ

もしプログラムが使用された場合、 httpd が起動されたユーザとして実行されます。これはサーバが root によって起動された場合は root になります。プログラムが 安全であるように留意してください。

Unix でないプラットフォームでファイルのパスを入力しているときは、 使用しているプラットフォームがバックスラッシュの使用を許可していた として、通常のスラッシュだけを使うように気をつけてください。 一般的に、設定ファイル中では常に普通のスラッシュのみを使うようにする 方が良いです。

二つめの引数はログファイルに何が書かれるかを指定します。 前にある LogFormat ディレクティブにより 定義された nickname か、ログの書式 のところで説明されている、明示的な format 文字列の どちらかを指定することができます。

例えば、以下の二つのディレクティブ群は全く同じ効果をもたらします:

# CustomLog with format nickname
LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog logs/access_log common

# CustomLog with explicit format string
CustomLog logs/access_log "%h %l %u %t \"%r\" %>s %b"

三つ目の引数は省略可能で、サーバの環境にある変数があるかないかに 応じてリクエストをログ収集するかどうかを制御するために使うことができます。 指定された環境変数がリクエストに対して 設定されていた場合 ('env=!name' 文が使われたときは 設定されていない場合)、リクエストがログ収集されます。

環境変数は mod_setenvif モジュールと mod_rewrite モジュールの両方もしくは 片方を用いてリクエストごとに設定することができます。 例えば、サーバにあるすべての GIF 画像へのリクエストを別のログファイル には記録したいけれど、メインログには記録したくない、というときは 以下のものを使うことができます:

SetEnvIf Request_URI \.gif$ gif-image
CustomLog gif-requests.log common env=gif-image
CustomLog nongif-requests.log common env=!gif-image

古い RefererIgnore ディレクティブと同じ挙動をさせたい場合は、 次のようにします:

SetEnvIf Referer example\.com localreferer
CustomLog referer.log referer env=!localreferer

top

LogFormat ディレクティブ

説明:ログファイルで使用する書式を設定する
構文:LogFormat format|nickname [nickname]
デフォルト:LogFormat "%h %l %u %t \"%r\" %>s %b"
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Base
モジュール:mod_log_config

このディレクティブはアクセスログファイルの書式を指定します。

LogFormat ディレクティブは二つの形式のどちらかを とることができます。最初の形式では一つの引数のみが指定され、 続く TransferLog で指定されたログで使われるログの書式を設定します。この単独の引数では 上のカスタムログ書式で説明されているように format を明示的に指定することができます。 もしくは、下で説明されているように前に LogFormat ディレクティブで定義されたログの書式を nicknameを使って 参照することもできます。

LogFormat ディレクティブの二つめの形式は formatnickname を与えます。 フォーマット文字列全体を再び書くかわりに、 この nickname を続きの LogFormat ディレクティブや CustomLog ディレクティブで使うことができます。 Nickname を定義する LogFormat ディレクティブは 他には何もしません -- すなわち、ニックネームを定義 するだけで、実際に書式を適用してデフォルトにするということは行ないません。 ですから、これは続く TransferLog ディレクティブには影響を与えません。 さらに、LogFormat ディレクティブは既存の nickname を 使って別の nickname を定義することはできません。Nickname には パーセント記号 (%) が含まれていてはいけないことにも注意 してください。

LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common

top

TransferLog ディレクティブ

説明:ログファイルの位置を指定
構文:TransferLog file|pipe
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Base
モジュール:mod_log_config

このディレクティブは、ログ書式を直接指定できないことと、 条件付きロギングが無いことを除くと、CustomLog と全く同じ引数と効果があります。 直接ログ書式を指定する代わりに、ログの書式はそこまでで一番最後に指定された ニックネームを定義しない LogFormat ディレクティブ で定義されたものを使います。 もし他の書式が全く指定されていないときは Common Log Format が使われます。

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
TransferLog logs/access_log

mod/mod_log_forensic.html100644 0 0 24347 11237400230 13204 0ustar 0 0 mod_log_forensic - Apache HTTP サーバ
<-

Apache モジュール mod_log_forensic

This translation may be out of date. Check the English version for recent changes.
説明:サーバに送られたリクエストの forensic ロギング
ステータス:Extension
モジュール識別子:log_forensic_module
ソースファイル:mod_log_forensic.c
互換性:mod_unique_id はバージョン 2.1 からは必須では なくなった

概要

このモジュールはクライアントリクエストの forensic ロギングを 行ないます。ログ収集はリクエストの処理の前と後に行なわれますので、 forensic ログは各リクエストに対して二行ログ収集します。 Forensic ロガーは非常に厳密です。これは以下のことを意味します:

  • フォーマットは固定です。実行時にロギングフォーマットを変更することは できません。
  • データを書けない場合は子プロセスはその場で終了し、さらにコアを ダンプするかもしれません (CoreDumpDirectory ディレクティブの設定に依ります)。

Forensic ログの出力を検査するためには、 配布物の support ディレクトリにある check_forensic スクリプトが役に立つでしょう。

top

Forensic ログフォーマット

各リクエストは2回ログ収集されます。最初はリクエストが処理される (つまり、ヘッダを受け取った後) です。2度目のログは リクエストが処理された、通常のログ収集と同じときに 行なわれます。

各リクエストを識別するために、リクエストには 一意なリクエスト ID が割り当てられます。この forensic ID は フォーマット文字列 %{forensic-id}n を使うことで 通常の transfer ログにログ収集することもできます。 mod_unique_id を使っている場合は、それが生成する ID が使われます。

最初の行は forensic ID、リクエスト行と受け取ったすべてのヘッダを パイプ文字 (|) で分離してログ収集します。 例えば以下のようになります (実際はすべて同じ行になります):

+yQtJf8CoAB4AAFNXBIEAAAAA|GET /manual/de/images/down.gif HTTP/1.1|Host:localhost%3a8080|User-Agent:Mozilla/5.0 (X11; U; Linux i686; en-US; rv%3a1.6) Gecko/20040216 Firefox/0.8|Accept:image/png, etc...

最初のプラス文字がこのログは最初のログであることを示します。 二番目の行はマイナス文字と ID のみです:

-yQtJf8CoAB4AAFNXBIEAAAAA

check_forensic スクリプトは引数としてログファイルの名前を 取ります。+/- の ID の組を調べ、完了していない リクエストがある場合は警告を発します。

top

セキュリティの問題

ログファイルが保存されるディレクトリがサーバを起動したユーザ 以外で書き込み可能になっているときにセキュリティが破られる可能性が あることについての詳細はセキュリティのこつを 参照してください。

top

ForensicLog ディレクティブ

説明:Forensic ログのファイル名を設定する
構文:ForensicLog filename|pipe
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_log_forensic

ForensicLog ディレクティブは forensic 解析のための サーバへのリクエストをログ収集に使います。 各ログエントリには、普通の CustomLog ディレクティブを使ってリクエストと関連付けることの できる 一意な ID が割り当てられます。mod_log_forensicforensic-id というトークンを作成し、フォーマット文字列 %{forensic-id}n を使うことでそのトークンを transfer ログに 追加することができます。

引数はログが書き出される位置を指定し、以下の 2種類の値のどちらかを 取ることができます:

filename
ServerRoot からの 相対ファイル名
pipe
パイプ文字 "|" と、その後にログ情報を標準入力から 受け取るプログラム。プログラム名は ServerRoot からの相対パスとしても 指定できます。

セキュリティ:

プログラムを使う場合、そのプログラムは httpd を起動したユーザで 実行されます。つまり、サーバが root で実行された場合は root で 実行されるということです。プログラムが安全であるか、より権限の少ない ユーザに切り替えるようになっていることを確かめてください。

Unix 以外のプラットフォームでファイル名を入力するときは、 プラットフォームがバックスラッシュの使用を許可している場合でも、 スラッシュのみが使われるように気をつけてください。 普通は設定ファイルすべてにおいて、スラッシュの方を使用するように してください。

mod/mod_logio.html100644 0 0 11433 11237400230 11634 0ustar 0 0 mod_logio - Apache HTTP サーバ
<-

Apache モジュール mod_logio

This translation may be out of date. Check the English version for recent changes.
説明:リクエスト毎に入力バイト数と出力バイト数とをロギング
ステータス:Extension
モジュール識別子:logio_module
ソースファイル:mod_logio.c

概要

このモジュールはリクエストごとに受け取ったバイト数と 送信したバイト数のロギングを行なう機能を提供します。 記録される数字はリクエストのヘッダとレスポンスの本体を 反映した、実際にネットワークで受け取ったバイト値です。 入力では SSL/TLS の前に、出力では SSL/TLS の後に数えるので、 数字は暗号による変化も正しく反映したものになります。

このモジュールの使用には mod_log_config モジュールが 必要です。

ディレクティブ

このモジュールにディレクティブはありません。

トピック

参照

top

カスタムログ書式

このモジュールは新しいロギング用ディレクティブを加えます。 リクエスト自身の特徴はフォーマット文字列に、以下の様に置換される "%" ディレクティブを 入れることでログ収集されます:

フォーマット文字列 説明
%...I リクエストとヘッダを含む、受け取ったバイト数。 0 にはならない。
%...O ヘッダを含む、送信したバイト数。0 にはならない。

通常、この機能は以下の様に使用されます:

結合 I/O ログ書式:
"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %I %O"
mod/mod_mem_cache.html100644 0 0 41107 11237400230 12425 0ustar 0 0 mod_mem_cache - Apache HTTP サーバ
<-

Apache モジュール mod_mem_cache

This translation may be out of date. Check the English version for recent changes.
説明:URI をキーにしたコンテンツのキャッシュ
ステータス:Extension
モジュール識別子:mem_cache_module
ソースファイル:mod_mem_cache.c

概要

このモジュールは mod_cache必要とします。 これは mod_cache のサポートモジュールとして 動作し、メモリを使用したストレージ管理機構を提供します。 mod_mem_cache は二つのモードのどちらかで動作するように 設定できます: ファイル記述子のキャッシュかヒープ中のオブジェクトの キャッシュです。ローカルで生成されたコンテンツに対してキャッシュするときや、 mod_proxy を使って ProxyPass (つまりリバースプロキシ向け) に設定したときのバックエンドサーバのコンテンツに対して キャッシュをするときに、たいへん効果的です。

コンテンツのキャッシュへの保存と取得は URI に基づいたキーが使われます。 アクセス保護のかけられているコンテンツはキャッシュされません。

top

MCacheMaxObjectCount ディレクティブ

説明:キャッシュに保管されるオブジェクトの最大数
構文:MCacheMaxObjectCount value
デフォルト:MCacheMaxObjectCount 1009
コンテキスト:サーバ設定ファイル
ステータス:Extension
モジュール:mod_mem_cache

MCacheMaxObjectCount ディレクティブは キャッシュされるオブジェクトの最大数を指定します。 この値はハッシュテーブルを作成するときに使われます。 新しいオブジェクトを挿入するときに、オブジェクトの最大数に 達してしまっているとき、新しいオブジェクトをキャッシュできるように、 オブジェクトを一つ消去します。オブジェクトは MCacheRemovalAlgorithm で指定されたアルゴリズムに従って削除されます。

MCacheMaxObjectCount 13001

top

MCacheMaxObjectSize ディレクティブ

説明:キャッシュに保管できるドキュメントの最大サイズ (バイト)
構文:MCacheMaxObjectSize bytes
デフォルト:MCacheMaxObjectSize 10000
コンテキスト:サーバ設定ファイル
ステータス:Extension
モジュール:mod_mem_cache

MCacheMaxObjectSize はドキュメントを キャッシュするかどうかを判定する、最大のサイズをバイト数で設定します。

MCacheMaxObjectSize 6400000

MCacheMaxObjectSize の値は MCacheMinObjectSize で指定した値よりも大きくなければなりません。

top

MCacheMaxStreamingBuffer ディレクティブ

説明:ストリームされている応答をキャッシュ不能と決定するまでに メモリにバッファする最大量
構文:MCacheMaxStreamingBuffer size_in_bytes
デフォルト:MCacheMaxStreamingBuffer of 100000 か MCacheMaxObjectSize の少い方
コンテキスト:サーバ設定ファイル
ステータス:Extension
モジュール:mod_mem_cache

MCacheMaxStreamingBuffer ディレクティブは、 サイズが大きすぎてキャッシュできないと判断するまでの、 ストリーム応答のバッファのための最大バイト数を指定します。 ストリーム応答とは、コンテンツの全体がすぐには得られず、 Content-Length がわからない応答を指します。 ストリーム応答を行なうようなものにはプロキシされた応答や、 CGI スクリプトの出力などがあります。デフォルトではストリームの応答は Content-Length がない限りキャッシュされません。 このような動作になっている理由は、結局キャッシュに収まりきらないと 判断することになってしまうような、サイズの大きな応答のバッファリングに、 大量のメモリが消費されるのを避けるためです。 MCacheMaxStreamingBuffer ディレクティブを使うと、 Content-Length を含まない応答に対して指定された最大量まで バッファするようにできます。バッファを使い切ると、バッファ中の コンテンツは捨てられ、キャッシュ動作を中止します。

注:

MCacheMaxStreamingBuffer に非零の値を 使っても、クライアントへの応答の転送に特に遅延は発生しません。 mod_mem_cache はストリームコンテンツの断片を バッファにコピーした後、即座に、その部分をクライアントへの配送の 次段の出力フィルタに送ります。

# Enable caching of streamed responses up to 64KB:
MCacheMaxStreamingBuffer 65536

top

MCacheMinObjectSize ディレクティブ

説明:キャッシュに保管されるドキュメントの最小サイズ (バイト)
構文:MCacheMinObjectSize bytes
デフォルト:MCacheMinObjectSize 0
コンテキスト:サーバ設定ファイル
ステータス:Extension
モジュール:mod_mem_cache

MCacheMinObjectSize ディレクティブは、ドキュメントを キャッシュするかどうかを判定する、最小のサイズをバイト数で設定します。

MCacheMinObjectSize 10000

top

MCacheRemovalAlgorithm ディレクティブ

説明:キャッシュから削除するドキュメントを選ぶためのアルゴリズム
構文:MCacheRemovalAlgorithm LRU|GDSF
デフォルト:MCacheRemovalAlgorithm GDSF
コンテキスト:サーバ設定ファイル
ステータス:Extension
モジュール:mod_mem_cache

MCacheRemovalAlgorithm ディレクティブは、 キャッシュから削除するドキュメントを選択するためのアルゴリズムを 指定します。選択肢は二つあります:

LRU (Least Recently Used)
LRU 一番長くアクセスされていないドキュメントを削除します。
GDSF (GreadyDual-Size)
GDSF はキャッシュミスのコストとドキュメントのサイズをもとに、 ドキュメントのキャッシュに対して優先度をつけます。 優先度の一番低いドキュメントが最初に削除されます。

MCacheRemovalAlgorithm GDSF
MCacheRemovalAlgorithm LRU

top

MCacheSize ディレクティブ

説明:キャッシュに使われるメモリの最大量をバイト単位で指定
構文:MCacheSize KBytes
デフォルト:MCacheSize 100
コンテキスト:サーバ設定ファイル
ステータス:Extension
モジュール:mod_mem_cache

MCacheSize ディレクティブはキャッシュに 使われるメモリの大きさをキロバイト (1024 バイト単位) で設定します。 新しいオブジェクトをキャッシュに挿入することになり、オブジェクトの サイズが残りのメモリより大きい場合は、その新しいオブジェクトの挿入が 可能になるまで、古いオブジェクトが削除されていきます。 オブジェクトは MCacheRemovalAlgorithm で指定したアルゴリズムに従って削除されます。

MCacheSize 700000

MCacheSize の値は MCacheMaxObjectSize ディレクティブで指定した値より 大きくなければなりません。

mod/mod_mime.html100644 0 0 200245 11237400230 11473 0ustar 0 0 mod_mime - Apache HTTP サーバ
<-

Apache モジュール mod_mime

This translation may be out of date. Check the English version for recent changes.
説明:リクエストされたファイルの拡張子とファイルの振る舞い (ハンドラとフィルタ)、内容 (MIME タイプ、言語、文字セット、エンコーディング) とを関連付ける
ステータス:Base
モジュール識別子:mime_module
ソースファイル:mod_mime.c

概要

このモジュールは拡張子を使っていろいろな「メタ情報」をファイルに 関連付けるために使用されます。この情報はドキュメントのファイル名と MIME タイプ、言語、文字セット、エンコーディングとを関連付けます。 この情報はブラウザに送られますし、複数のファイルの中からユーザの好みの ものが選ばれるように、コンテントネゴシエーションでも使われます。 コンテントネゴシエーション に関する詳しい情報は mod_negotiation をご覧下さい。

AddCharset ディレクティブ、 AddEncoding ディレクティブ、 AddHandler ディレクティブ、 AddLanguage ディレクティブ、 AddType ディレクティブはすべて、 ファイルの拡張子をメタ情報にマップするために使用されます。 それぞれ、ドキュメントの文字セット (訳注: charset)、content-encoding, content-language, MIME タイプ (content-type) を設定します。 TypesConfig ディレクティブは拡張子を MIME タイプにマップするファイルを指定するために使用されます。

さらに、mod_mime はコンテンツを作成、処理する ハンドラフィルタ を設定することができます。AddHandler ディレクティブ、AddOutputFilter ディレクティブ、AddInputFilter ディレクティブは ドキュメントを扱うモジュールやスクリプトを制御します。 MultiviewsMatch ディレクティブは これらのディレクティブが指定したファイルの拡張子を mod_negotiation が Multiviews のマッチをとるときに 考慮するようにできます。

mod_mime はメタ情報をファイル名と関連付けますが、 core サーバにはあるコンテナ (たとえば, <Location>, <Directory>, <Files>) の中のすべてのファイルを特定の メタ情報と関連付けるディレクティブがあります。これらのディレクティブには ForceType, SetHandler, SetInputFilter, SetOutputFilter があります。 コアのディレクティブは mod_mime により定義された ファイル名の拡張子のマッピングすべてを上書きします。

ファイルのメタ情報を変えても Last-Modified ヘッダの値は変わらないことに注意してください。ですから、 それらを変更した場合は、クライアントやプロキシで以前にキャッシュされた コピーがそのときのヘッダとともに使われる可能性があります。 メタ情報 (言語、コンテントタイプ、文字セット、エンコーディング) を 変更したときは、すべての訪問者が正しいコンテントヘッダを 受け取るように、影響を受けるファイルに 'touch' コマンドを実行する (最終更新日を更新する) 必要があるかもしれません。

top

複数の拡張子のあるファイル

ファイルは複数の拡張子を持つことができ、拡張子の順番は通常は関係ありません。例えば、ファイル welcome.html.fr がコンテントタイプは text/html に、言語はフランス語にマップされる場合、welcome.fr.html もまったく同じ情報にマップされます。 同じメタ情報にマップされる拡張子が複数あるときには、言語と コンテントエンコーディングを除いて、 右側にあるものが使用されます。たとえば、.gif が MIME タイプ image/gif にマップされ、.html が MIME タイプ text/html にマップされる場合は、ファイル welcome.gif.html は MIME タイプ text/html に関連付けられます。

リソースに複数の言語やエンコーディングを関連付けること ができるため、 言語コンテントエンコーディングは前のものに追加されていきます。 たとえば、ファイル welcome.html.en.deContent-Language: en, deContent-Type: text/html として送信されます。

複数の拡張子のあるファイルが MIME タイプとハンドラの両方に関連付けられているときは注意する必要があります。 その場合、普通はリクエストがハンドラに関連付けられた モジュールによって扱われることになります。たとえば、拡張子 .imap が (mod_imagemap の) imap-file にマップされていて、.html が MIME タイプ text/html にマップされているときは、ファイル world.imap.htmlimap-file ハンドラと text/html MIME タイプに関連付けられます。ファイルが処理されるときは imap-file ハンドラが使用されますので、そのファイルは mod_imagemap のイメージマップファイルとして扱われることになります。

top

コンテントエンコーディング

特定の MIME タイプのファイルはインターネットでの転送を簡単にするために、 さらに符号化することができます。これは通常は gzip の ような圧縮のことを指しますが、pgp のような暗号化や、 バイナリファイルを ASCII (テキスト) 形式で送るために考案された UUencoding のことを指すこともあります。

HTTP/1.1 RFC 14.11 節では次のように記述されています。

Content-Encoding エンティティヘッダフィールドはメディアタイプの 修飾子として使われます。それが存在していれば、値はエンティティボディに どの追加の符号化が適用されたかを示し、Content-Type ヘッダフィールドに 書かれているメディアタイプを得るためにどの復号機構を適用すべきか、も 示していることになります。Content-Encoding は主に、元のメディアタイプの 同一性を失うことなくドキュメントを圧縮することを可能にするために 使用されます。

複数のファイル拡張子 (複数の拡張子については 上の節 を参照) 使うことで、 ファイルのタイプエンコーディングを指定することが できます。

たとえば、Microsoft Word のドキュメントがあり、サイズを小さくするために pkzip されているとします。.doc 拡張子が Microsoft Word の ファイルタイプと関連付けられていて、.zip 拡張子が pkzip ファイルエンコーディングと関連付けられていると、ファイル Resume.doc.zip は pkzip された Word ドキュメントである ということがわかります。

クライアントのブラウザにエンコーディング方法を知らせるために、 Apache はリソースと共に Content-Encoding ヘッダを 送ります。

Content-encoding: pkzip

top

文字セットと言語

ファイルタイプとファイルエンコーディングの他に重要な情報は ドキュメントの書かれている言語と、どの文字セットでファイルが表示 されるべきか、というものです。たとえば、ドキュメントはベトナムの アルファベットやキリル文字で書かれていて、そのように表示される 必要があるかもしれません。この情報もまた、HTTP ヘッダで 送信されます。

文字セット、言語、エンコーディング、mime タイプはすべて コンテントネゴシエーション (mod_negotiation 参照) の最中に、複数の文字セット、言語、エンコーディング、MIME タイプからなる 代替物があるときにどのドキュメントをクライアントに送るのかを 決定するときに使われます。AddCharset, AddEncoding, AddLanguage, AddType の各ディレクティブで作成された 拡張子の関連付け (と MimeMagicFile でリストされている 拡張子) がこの選択に参加します。AddHandler, AddInputFilter, AddOutputFilter の 各ディレクティブでのみ関連付けられている拡張子は MultiviewsMatch ディレクティブを 使うことでマッチの 処理に含めることも外すこともできます。

Charset

さらに情報を伝えるために、Apache は文書の言語を Content-Language ヘッダで送ることもあります。 また、情報を正しく表示するために使用すべき文字セットを示すために Conten-Type ヘッダに情報を追加することもあります。

Content-Language: en, fr
Content-Type: text/plain; charset=ISO-8859-1

言語の指定は二文字の短縮形で行なわれます。charset が 使用すべき文字セットの名前です。

top

AddCharset ディレクティブ

説明:ファイル名の拡張子を指定された文字セットにマップする
構文:AddCharset charset extension [extension] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime

AddCharset ディレクティブは、 与えられた拡張子を指定された charset にマップします。charset は、拡張子 extension を含んでいるファイル名の MIME charset パラメータです。新しいマッピングは既にある他のマッピングに追加され、同じ拡張子 extension のためのマッピングを上書きします。

AddLanguage ja .ja
AddCharset EUC-JP .euc
AddCharset ISO-2022-JP .jis
AddCharset SHIFT_JIS .sjis

この場合、ドキュメント xxxx.ja.jis は charset が ISO-2022-JP の日本語のドキュメントとして扱われます (xxxx.jis.ja も同様)。AddCharset ディレクティブは、ドキュメントが適切に解釈され表示されるように、 ドキュメントの charset の情報をクライアントに教えるために役に立ちます。 また、サーバがクライアントの charset の優先度に基づいて複数のドキュメントの中からドキュメントを選ぶコンテントネゴシエーションのためにも役に立ちます。

引数 extensionは大文字小文字を区別せず、 最初のドットはあってもなくても構いません。

参照

top

AddEncoding ディレクティブ

説明:ファイル名の拡張子を指定されたエンコーディング にマップする
構文:AddEncoding MIME-enc extension [extension] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime

AddEncoding ディレクティブは、 与えられた拡張子を指定されたエンコーディングにマップします。 MIME-enc は、拡張子 extension を含んだドキュメントに使用する MIME エンコーディングです。 この新しいマッピングは既にある他のマッピングに追加され、 同じ拡張子 extension のためのマッピングを上書きします。

AddEncoding x-gzip .gz
AddEncoding x-compress .Z

これは、拡張子 .gz を含むファイル名が x-gzip エンコーディングを使ってエンコードされていることと、拡張子 .Z を含むファイル名が x-compress でエンコードされていることを指定します。

古いクライアントは x-zipx-compress が返ってくることを期待しますが、標準規格ではそれぞれ gzipcompress と等価であることになっています。Apache は、コンテントエンコーディングの比較をするときには、先頭にある x- を無視します。Apache がエンコーディング付きで応答を返すときは、クライアントが要求した形式 (すなわちx-foofoo) を使用します。要するに、この二つのエンコーディングの場合は常に x-gzipx-compress を使うべきである、ということです。deflate のようなより新しいエンコーディングでは、x- なしで指定してください。

引数 extension は大文字小文字を区別せず、 最初のドットはあってもなくても構いません。

top

AddHandler ディレクティブ

説明:ファイル名の拡張子を指定されたハンドラにマップする
構文:AddHandler handler-name extension [extension] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime

拡張子 extension が名前にあるファイルは指定された handler-name に扱われます。 この新しいマッピングは既にある他のマッピングに追加され、 同じ拡張子 extension のためのマッピングを上書きします。たとえば、拡張子 ".cgi" で終わるファイルを CGI スクリプトとして扱いたいときは、以下の設定をします。

AddHandler cgi-script .cgi

これを httpd.conf ファイルに記述することで、拡張子 ".cgi" のファイルは CGI プログラムとして扱われます。

引数 extension は大文字小文字を区別せず、 最初のドットはあってもなくても構いません。

参照

top

AddInputFilter ディレクティブ

説明:ファイルの拡張子をクライアントのリクエストを処理する フィルタにマップする
構文:AddInputFilter filter[;filter...] extension [extension] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime
互換性:2.0.26 以降で使用可能

AddInputFilter はファイルの拡張子 extension をクライアントのリクエストや POST がサーバに来たときに 処理をするフィルタにマップします。 これは、SetInputFilter ディレクティブも 含め、他の場所で定義されているフィルタに加えられます。 このマッピングはすでにあるものより優先されてマージされ、 同じ extension に対する既存のマッピングを上書きします。

複数のフィルタを指定するときは、データを処理する順番にセミコロンで 繋いで書く必要があります。フィルタと extension との 両方の引数は大文字小文字を区別せず、拡張子の最初のドットは あってもなくても構いません。

参照

top

AddLanguage ディレクティブ

説明:ファイル名を指定された言語にマップ
構文:AddLanguage MIME-lang extension [extension] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime

AddLanguage ディレクティブは、与えられた拡張子を指定された content language にマップします。MIME-lang は、拡張子 extension を含んでいるファイル名の MIME における言語です。 この新しいマッピングは既にあるマッピングに追加され、同じ拡張子 extension のためのマッピングを上書きします。

AddEncoding x-compress .Z
AddLanguage en .en
AddLanguage fr .fr

この場合、xxxx.en.Z ドキュメントは compress された英語のドキュメントとして扱われます (xxxx.Z.en も同様)。content language はクライアントに通知されますが、 ブラウザがこの情報を使うことはおそらくありません。 AddLanguage ディレクティブは、サーバがクライアントの言語の優先度に基づいて複数の ドキュメントの中からドキュメントを選ぶコンテントネゴシエーションのためにより役に立ちます。

複数の言語が同じ拡張子に割り当てられているときは、 最後のものが使用されます。すなわち、次のような場合、

AddLanguage en .en
AddLanguage en-gb .en
AddLanguage en-us .en

拡張子 .en のあるドキュメントは en-us として扱われます。

引数 extension は大文字小文字を区別せず、 最初のドットはあってもなくても構いません。

参照

top

AddOutputFilter ディレクティブ

説明:ファイル名の拡張子をサーバからの応答を処理するフィルタに マップする
構文:AddOutputFilter filter[;filter...] extension [extension] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime
互換性:2.0.26 以降で使用可能

AddOutputFilter ディレクティブは 拡張子 extension をサーバの応答がクライアントに送られる 前に処理するフィルタを定義します。 これは SetOutputFilter ディレクティブと AddOutputFilterByType ディレクティブ を含め、他の場所で定義されているフィルタに加えられます。 この新しいマッピングは既にあるマッピングに追加され、同じ拡張子 extension のためのマッピングを上書きします。

例えば、以下の設定はすべての .shtml ファイルを SSI で処理し、 その出力を mod_deflate を使って圧縮します。

AddOutputFilter INCLUDES;DEFLATE shtml

複数のフィルタを指定するときは、データを処理する順番にセミコロンで 繋いで書く必要があります。filterextension の 両引数は大文字小文字を区別せず、拡張子の最初のドットは あってもなくても構いません。

参照

top

AddType ディレクティブ

説明:ファイル名の拡張子を指定されたコンテントタイプにマップ
構文:AddType MIME-type extension [extension] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime

AddType ディレクティブは、 与えられた拡張子を指定されたコンテントタイプにマップします。 MIME-type は拡張子 extension を含んだドキュメントに使用する MIME タイプです。 この新しいマッピングは既にあるマッピングに追加され、同じ拡張子 extension のためのマッピングを上書きします。 このディレクティブは MIME タイプファイル (TypesConfig ディレクティブを参照) に無いマッピングを追加するために使用することができます。

AddType image/gif .gif

新しい MIME タイプは、TypesConfig ファイルを変更するのではなく、AddType ディレクティブを使って追加することが推奨されています。

引数 extension は大文字小文字を区別せず、 最初のドットはあってもなくても構いません。

参照

top

DefaultLanguage ディレクティブ

説明:あるスコープのすべてのファイルを指定された言語に 設定する
構文:DefaultLanguage MIME-lang
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime

DefaultLanguage ディレクティブは、Apache がディレクティブのスコープ (例えば、その時点の <Directory> の範囲) にある、明示的な言語拡張子 (AddLanguage で設定される .fr.de) のない全てのファイルを、指定された MIME-lang 言語であるとみなすようにします。 これにより、すべてのファイル名を変えることなく、 ディレクトリがオランダ語のコンテントを含んでいる、 というようなことを指定することができます。 拡張子を使用して言語を指定する方法と違い、 DefaultLanguage は一つの言語しか指定できないことに注意してください。

DefaultLanguage ディレクティブが有効でなく、ファイルに AddLanguage で設定された言語の拡張子がないときは、 ファイルには言語属性がないとみなされます。

DefaultLanguage en

参照

top

ModMimeUsePathInfo ディレクティブ

説明:path_info コンポーネントをファイル名の一部として扱うように mod_mime に通知する
構文:ModMimeUsePathInfo On|Off
デフォルト:ModMimeUsePathInfo Off
コンテキスト:ディレクトリ
ステータス:Base
モジュール:mod_mime
互換性:Apache 2.0.41 以降

ModMimeUsePathInfo ディレクティブは、 mod_mime の持つディレクティブを リクエストに適用させるために、ファイル名と path_info URL コンポーネントを結合させるために使用します。 デフォルトでは「 Off 」で、path_info コンポーネントは無視されます。

このディレクティブは、バーチャルファイルシステムを使用している際に 推奨されるディレクティブです。

ModMimeUsePathInfo On

/bar が存在して (foo.shtml は存在しない) ModMimeUsePathInfoOn であるとして、 /bar/foo.shtml に対するリクエストを発行した場合、 mod_mime は入ってきたリクエストを /bar/foo.shtml として扱い、 AddOutputFileter INCLUDES .shtml のようなディレクティブは INCLUDES フィルタをリクエストに付加させます。 ModMimeUsePathInfo が設定されなければ、 INCLUDES フィルタは付加されません。

参照

top

MultiviewsMatch ディレクティブ

説明:MultiViews でのマッチングの検索に含ませる ファイルのタイプを指定する
構文:MultiviewsMatch Any|NegotiatedOnly|Filters|Handlers [Handlers|Filters]
デフォルト:MultiviewsMatch NegotiatedOnly
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime
互換性:2.0.26 以降で使用可能

MultiviewsMatch を使用することで、 mod_negotiation の Multiviews に 3 種類の異なる挙動をさせることができます。 Multiviews を使用すると、ファイル (例 index.html) に対するリクエストに対して、ネゴシエーションする拡張子がベースに付いたもの (index.html.en, index.html.frindex.html.gz) をマッチさせることができます。

NegotiatedOnly オプションでは、ベース名に続く拡張子全てが コンテントネゴシエーションで mod_mime が認識する拡張子 ( 文字セット、コンテントタイプ、言語やエンコーディング) に関連付けられていなければなりません。これは副作用の最も少ない 最も的確な実装で、デフォルトになっています。

ハンドラとフィルタの両方もしくは片方と関連付けられた拡張子を含めるには、 MultiviewsMatch ディレクティブに Handlers, Filters またはその両方のオプションをセットします。 もし他の条件が同じであれば、最も小さいファイルが送信されます。 例えば、500 文字の index.html.cgi と 1000 バイトの index.html.pl であれば、.cgi のファイルが優先されます。.asis ファイルを利用しているユーザは、 .asis ファイルが asis-handler に関連付けられているときには、 ハンドラオプションの使用を好むでしょう。

最後に、mod_mime が認識しない拡張子であろうとも、 どんな拡張子でもマッチさせる Any が使用できます。 この挙動は Apache 1.3 のときと同じもので、予期しない動作、例えば .old.bak ファイルといったウェブマスタが送信を意図していない ファイルを送信する、といった動作を行なう可能性があります。

例えば次の設定では、ハンドラやフィルタが Multiviews に参加することが できますし、未知のファイルは除外することができます。

MultiviewsMatch Handlers Filters

参照

top

RemoveCharset ディレクティブ

説明:ファイルの拡張子に関連付けられたすべての文字セット を解除する
構文:RemoveCharset extension [extension] ...
コンテキスト:バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime
互換性:2.0.24 以降で使用可能

RemoveCharset ディレクティブ は与えられた拡張子に関連付けられた文字セットを取り消します。 これにより、サブディレクトリにある .htaccess ファイルが親ディレクトリやサーバの設定ファイル から継承した関連付けを取り消すことができます。例えば:

extension は大文字小文字を区別しません。 また、最初のドットはあってもなくても構いません。

RemoveCharset .html .shtml

top

RemoveEncoding ディレクティブ

説明:ファイルの拡張子に関連付けられたすべてのコンテントエンコーディング を解除する
構文:RemoveEncoding extension [extension] ...
コンテキスト:バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime

RemoveEncoding ディレクティブは、 与えられた拡張子に関連付けられたエンコーディングを取り消します。 これにより、サブディレクトリにある .htaccess ファイルが親ディレクトリやサーバの設定ファイルから継承した関連付けを 取り消すことができます。

/foo/.htaccess:

AddEncoding x-gzip .gz
AddType text/plain .asc
<Files *.gz.asc>
RemoveEncoding .gz
</Files>

これは、foo.gz は gzip でエンコードされていることを指定しますが、foo.gz.asc はエンコードされていないプレーンテキストの ファイルであるということを指定します。

注意

RemoveEncodingAddEncoding ディレクティブので処理されますので、 同じディレクトリの設定中に両方が現れると、 後者の効果が打ち消される可能性があります。

extension は大文字小文字を区別しません。 また、最初のドットはあってもなくても構いません。

top

RemoveHandler ディレクティブ

説明:ファイルの拡張子に関連付けられたすべてのハンドラを 解除する
構文:RemoveHandler extension [extension] ...
コンテキスト:バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime

RemoveHandler ディレクティブ は与えられた拡張子に関連付けられたハンドラを取り消します。 これにより、サブディレクトリにある .htaccess ファイルが親ディレクトリやサーバの設定ファイル から継承した関連付けを取り消すことができます。たとえば:

/foo/.htaccess:

AddHandler server-parsed .html

/foo/bar/.htaccess:

RemoveHandler .html

これは、/foo/bar ディレクトリの .html ファイルは SSI (mod_include モジュール参照) ではなく、 普通のファイルとして扱われるようにする効果があります。

extension は大文字小文字を区別しません。 また、最初のドットはあってもなくても構いません。

top

RemoveInputFilter ディレクティブ

説明:ファイル拡張子に関連付けられた入力フィルタを解除する
構文:RemoveInputFilter extension [extension] ...
コンテキスト:バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime
互換性:2.0.26 以降で使用可能

RemoveInputFilter ディレクティブは 指定されたファイル拡張子に関連付けられた入力フィルタを解除します。 これを利用することで、親ディレクトリやサーバ設定ファイルから 継承した関連付けを サブディレクトリ内において .htaccess ファイルで取り消すことができます。

extension 引数は大文字小文字を区別しません。また、 最初のドットはあってもなくても構いません。

参照

top

RemoveLanguage ディレクティブ

説明:ファイル拡張子に関連付けられた言語を解除する
構文:RemoveLanguage extension [extension] ...
コンテキスト:バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime
互換性:2.0.24 以降で使用可能

RemoveLanguage ディレクティブは 指定されたファイル拡張子に関連付けられた言語を解除します。 これを利用することで、親ディレクトリやサーバ設定ファイルから 継承した関連付けを サブディレクトリ内において .htaccess ファイルで取り消すことができます。

extension 引数は大文字小文字を区別しません。また、 最初のドットはついてもつかなくても構いません。

top

RemoveOutputFilter ディレクティブ

説明:ファイル拡張子に関連付けられた出力フィルタを解除する
構文:RemoveOutputFilter extension [extension] ...
コンテキスト:バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime
互換性:2.0.26 以降でのみ使用可能

RemoveOutputFilter ディレクティブは 指定されたファイル拡張子に関連付けられた出力フィルタを解除します。 これを利用することで、親ディレクトリやサーバ設定ファイルから 継承した関連付けを サブディレクトリ内において .htaccess ファイルで取り消すことができます。

extension は大文字小文字を区別しません。 また、最初のドットはあってもなくても構いません。

RemoveOutputFilter shtml

参照

top

RemoveType ディレクティブ

説明:ファイルの拡張子と関連付けられたコンテントタイプを 解除する
構文:RemoveType extension [extension] ...
コンテキスト:バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_mime

RemoveType ディレクティブは与えられた拡張子の MIME タイプの関連付けを取り消します。これにより、 サブディレクトリにある .htaccess ファイルが親ディレクトリやサーバの設定ファイルから継承した 関連付けを取り消すことができます。たとえば:

/foo/.htaccess:

RemoveType .cgi

これは /foo/ ディレクトリ以下の .cgi ファイルの特別な扱いを取り消します。ファイルは DefaultType として扱われます。

注意

RemoveType ディレクティブは AddType ディレクティブのに処理されますので、 両方が同じディレクトリの設定中に現れた場合、 後者の効果が打ち消される可能性があります。

extension は大文字小文字を区別しません。 また、最初のドットはあってもなくても構いません。

top

TypesConfig ディレクティブ

説明:mime.types ファイルの位置
構文:TypesConfig file-path
デフォルト:TypesConfig conf/mime.types
コンテキスト:サーバ設定ファイル
ステータス:Base
モジュール:mod_mime

TypesConfig ディレクティブは、MIME タイプ設定ファイルの位置を設定します。filenameServerRoot からの相対パスです。 このファイルはファイルの拡張子からコンテントタイプへの デフォルトのマッピングを設定します。 ほとんどの管理者は、よく使われるファイル名の拡張子を IANA に登録されたコンテントタイプに関連付けている、 Apache の mime.types ファイルを使います。 現在の一覧は http://www.iana.org/assignments/media-types/index.html で管理されています。これは、主要なメディアタイプの定義を提供して、 必要ところを AddType で 上書きする、という方法で httpd.conf を簡略にします。 mime.types はサーバをアップグレードしたときに 置き換えられるかもしれないので、そのファイルを直接 編集しないでください。

ファイルは、AddType ディレクティブの引数と同じ形式の行で構成されます。

MIME-type [extension] ...

拡張子の大文字小文字は区別されません。空行やハッシュ (`#') で始まる行は無視されます。

(1) IANA に既に登録されている、あるいは (2) 広く受け入れられていてプラットホーム間でファイル拡張子に衝突がない、 という場合でなければ、配布中の mime.types ファイルに新たなものを登録するように Apache HTTP Server Project にリクエストしないでください。 category/x-subtype のリクエストは自動的に却下されますし、 言語や文字セットの名前空間で既に使用されていて、衝突の可能性のある 2 文字の拡張子も却下されます。

参照

mod/mod_mime_magic.html100644 0 0 32371 11237400230 12616 0ustar 0 0 mod_mime_magic - Apache HTTP Server
<-

Apache Module mod_mime_magic

Description:Determines the MIME type of a file by looking at a few bytes of its contents
Status:Extension
ModuleIdentifier:mime_magic_module
SourceFile:mod_mime_magic.c

Summary

This module determines the MIME type of files in the same way the Unix file(1) command works: it looks at the first few bytes of the file. It is intended as a "second line of defense" for cases that mod_mime can't resolve.

This module is derived from a free version of the file(1) command for Unix, which uses "magic numbers" and other hints from a file's contents to figure out what the contents are. This module is active only if the magic file is specified by the MimeMagicFile directive.

top

Format of the Magic File

The contents of the file are plain ASCII text in 4-5 columns. Blank lines are allowed but ignored. Commented lines use a hash mark (#). The remaining lines are parsed for the following columns:

ColumnDescription
1 byte number to begin checking from
">" indicates a dependency upon the previous non-">" line
2

type of data to match

byte single character
short machine-order 16-bit integer
long machine-order 32-bit integer
string arbitrary-length string
date long integer date (seconds since Unix epoch/1970)
beshort big-endian 16-bit integer
belong big-endian 32-bit integer
bedate big-endian 32-bit integer date
leshort little-endian 16-bit integer
lelong little-endian 32-bit integer
ledate little-endian 32-bit integer date
3 contents of data to match
4 MIME type if matched
5 MIME encoding if matched (optional)

For example, the following magic file lines would recognize some audio formats:

# Sun/NeXT audio data
0      string      .snd
>12    belong      1       audio/basic
>12    belong      2       audio/basic
>12    belong      3       audio/basic
>12    belong      4       audio/basic
>12    belong      5       audio/basic
>12    belong      6       audio/basic
>12    belong      7       audio/basic
>12    belong     23       audio/x-adpcm

Or these would recognize the difference between *.doc files containing Microsoft Word or FrameMaker documents. (These are incompatible file formats which use the same file suffix.)

# Frame
0  string  \<MakerFile        application/x-frame
0  string  \<MIFFile          application/x-frame
0  string  \<MakerDictionary  application/x-frame
0  string  \<MakerScreenFon   application/x-frame
0  string  \<MML              application/x-frame
0  string  \<Book             application/x-frame
0  string  \<Maker            application/x-frame

# MS-Word
0  string  \376\067\0\043            application/msword
0  string  \320\317\021\340\241\261  application/msword
0  string  \333\245-\0\0\0           application/msword

An optional MIME encoding can be included as a fifth column. For example, this can recognize gzipped files and set the encoding for them.

# gzip (GNU zip, not to be confused with
#       [Info-ZIP/PKWARE] zip archiver)

0  string  \037\213  application/octet-stream  x-gzip
top

Performance Issues

This module is not for every system. If your system is barely keeping up with its load or if you're performing a web server benchmark, you may not want to enable this because the processing is not free.

However, an effort was made to improve the performance of the original file(1) code to make it fit in a busy web server. It was designed for a server where there are thousands of users who publish their own documents. This is probably very common on intranets. Many times, it's helpful if the server can make more intelligent decisions about a file's contents than the file name allows ...even if just to reduce the "why doesn't my page work" calls when users improperly name their own files. You have to decide if the extra work suits your environment.

top

Notes

The following notes apply to the mod_mime_magic module and are included here for compliance with contributors' copyright restrictions that require their acknowledgment.

mod_mime_magic: MIME type lookup via file magic numbers
Copyright (c) 1996-1997 Cisco Systems, Inc.

This software was submitted by Cisco Systems to the Apache Group in July 1997. Future revisions and derivatives of this source code must acknowledge Cisco Systems as the original contributor of this module. All other licensing and usage conditions are those of the Apache Group.

Some of this code is derived from the free version of the file command originally posted to comp.sources.unix. Copyright info for that program is included below as required.

- Copyright (c) Ian F. Darwin, 1987. Written by Ian F. Darwin.

This software is not subject to any license of the American Telephone and Telegraph Company or of the Regents of the University of California.

Permission is granted to anyone to use this software for any purpose on any computer system, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The author is not responsible for the consequences of use of this software, no matter how awful, even if they arise from flaws in it.
  2. The origin of this software must not be misrepresented, either by explicit claim or by omission. Since few users ever read sources, credits must appear in the documentation.
  3. Altered versions must be plainly marked as such, and must not be misrepresented as being the original software. Since few users ever read sources, credits must appear in the documentation.
  4. This notice may not be removed or altered.

For compliance with Mr Darwin's terms: this has been very significantly modified from the free "file" command.

  • all-in-one file for compilation convenience when moving from one version of Apache to the next.
  • Memory allocation is done through the Apache API's pool structure.
  • All functions have had necessary Apache API request or server structures passed to them where necessary to call other Apache API routines. (i.e., usually for logging, files, or memory allocation in itself or a called function.)
  • struct magic has been converted from an array to a single-ended linked list because it only grows one record at a time, it's only accessed sequentially, and the Apache API has no equivalent of realloc().
  • Functions have been changed to get their parameters from the server configuration instead of globals. (It should be reentrant now but has not been tested in a threaded environment.)
  • Places where it used to print results to stdout now saves them in a list where they're used to set the MIME type in the Apache request record.
  • Command-line flags have been removed since they will never be used here.
top

MimeMagicFile Directive

Description:Enable MIME-type determination based on file contents using the specified magic file
Syntax:MimeMagicFile file-path
Context:server config, virtual host
Status:Extension
Module:mod_mime_magic

The MimeMagicFile directive can be used to enable this module, the default file is distributed at conf/magic. Non-rooted paths are relative to the ServerRoot. Virtual hosts will use the same file as the main server unless a more specific setting is used, in which case the more specific setting overrides the main server's file.

Example

MimeMagicFile conf/magic

mod/mod_negotiation.html100644 0 0 45310 11237400230 13044 0ustar 0 0 mod_negotiation - Apache HTTP サーバ
<-

Apache モジュール mod_negotiation

This translation may be out of date. Check the English version for recent changes.
説明:コンテントネゴシエーション 機能を提供する
ステータス:Base
モジュール識別子:negotiation_module
ソースファイル:mod_negotiation.c

概要

コンテントネゴシエーション、より正確にはコンテンツの選択機能は、 複数用意されているドキュメントから、クライアントの能力に一番合った ドキュメントを選択する機能です。この実装は二つあります。

  • タイプマップ (type-map ハンドラで扱われるファイル)。これは variants を含んでいるファイルを明示的に指定します。
  • MultiViews の探索 (MultiViews Option で有効になります)。 サーバが暗黙の内にファイル名のパターンマッチを行ない、 その結果から選択します。
top

タイプマップ

タイプマップは RFC 822 のメールヘッダに類似した書式です。 ドキュメントの記述が空行で分離されて書かれていて、ハッシュ文字 ('#') で始まる行はコメントとして扱われます。 ドキュメントの説明は複数のヘッダレコードから構成されます。 レコードは、続きの行が空白で始まっていると複数の行にまたがります。 最初の空白が消去されて、前の行とつなげて 1 行として扱われます。 ヘッダレコードはキーワード名の後に値が続くという形式で、 キーワード名は常にコロンで終わります。空白はヘッダ名と値の間、 値のトークンの間に入れることができます。 使用可能なヘッダは以下のとおりです:

Content-Encoding:
ファイルのエンコーディング。Apache は AddEncoding ディレクティブ で定義されたエンコーディングだけを認識します。通常 compress されたファイルのための x-compress と gzip されたファイルのための x-gzip を含みます。 エンコーディングの比較をするときは、接頭辞 x- は無視されます。
Content-Language:
インターネット標準の言語タグ (RFC 1766) で定義されている言語の種類。例えば、en は英語を表します。 複数の言語が格納される場合はコンマで区切られます。
Content-Length:
ファイルの長さ (バイト数)。 このヘッダがない場合、ファイルの実際の長さが使用されます。
Content-Type:
ドキュメントの MIME メディアタイプ、オプショナルなパラメータ付き。パラメータの構文は name=value で、メディアタイプや他のパラメータとはセミコロンで分離されます。 共通のパラメータは以下のとおり:
level
メディアタイプのバージョンを示す整数。 text/html では 2 がデフォルトで、その他の場合は 0 がデフォルトです。
qs
クライアントの能力に関係なく、variant を他と比較したときの相対的な「品質」で、0.0 から 1.0 の範囲の浮動点小数。 例えば、写真を表現しようとしているときは普通は JPEG ファイルの方が ASCII ファイルよりも高い品質になります。 しかし、リソースが ASCII アートで表現されているときは、ASCII ファイルの方が JPEG ファイルよりも高い品質になります。このように、qs はリソース毎に特有の値を取ります。

Content-Type: image/jpeg; qs=0.8

URI:
(指定のメディアタイプ、コンテントエンコーディングの) variant の ファイルの uri. これは、マップファイルからの相対 URL として 解釈されます。同じサーバに存在しなければならず、クライアントが 直接リクエストしたときにアクセスを許可されるものでなければなりません。
Body:
Apache 2.0 で新設されたこの Body ヘッダを使って、 リソースの実際の内容をタイプマップファイルに書くことができます。 このヘッダは本文の内容の区切りとなる文字列で始まる必要があります。 タイプマップファイルの続く行は、区切り文字列が見つかるまで、 リソースの本文になります。

Example:

Body:----xyz----
<html>
<body>
<p>Content of the page.</p>
</body>
</html>
----xyz----

top

MultiViews

MultiViews 探索は、Multiviews Options ディレクティブにより有効になります。 サーバが /some/dir/foo へのリクエストを受け取り、/some/dir/foo が存在 しない場合、サーバはディレクトリを読んで、 foo.* にあてはまる全てのファイルを探し、 事実上それらのファイルをマップするタイプマップを作ります。 そのとき、メディアタイプとコンテントエンコーディングは、 そのファイル名を直接指定したときと同じものが割り当てられます。 それからクライアントの要求に一番合うものを選び、 そのドキュメントを返します。

ファイルを選択する際に、関連するコンテントネゴシエーションの メタ情報を持たないファイルについて、判定を行うかどうかを MultiViewsMatch ディレクティブで設定します。

top

CacheNegotiatedDocs ディレクティブ

説明:コンテントネゴシエーションされたドキュメントをプロキシサーバが キャッシュできるようにする
構文:CacheNegotiatedDocs On|Off
デフォルト:CacheNegotiatedDocs Off
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Base
モジュール:mod_negotiation
互換性:バージョン 2.0で構文が変わりました

このディレクティブが設定されていると、コンテントネゴシエーション をした結果のドキュメントのキャッシュを許可します。 これは、プロキシの後ろにいるクライアントが能力に一番合った ドキュメントではなく、 キャッシュをより効果的にするものを得る可能性があるということです。

このディレクティブは HTTP/1.0 ブラウザからのリクエスト のみに適用されます。HTTP/1.1 は、 交渉されたドキュメントのキャッシュに対してずっとよい制御が可能なので、 このディレクティブは HTTP/1.1 のリクエストには影響しません。

2.0 より前のバージョンでは、 CacheNegotiatedDocs は引数を取らず、 ディレクティブが存在することで on の動作をしていました。

top

ForceLanguagePriority ディレクティブ

説明:要求に合う単独のドキュメントが見つからなかったときに行なうことを指定
構文:ForceLanguagePriority None|Prefer|Fallback [Prefer|Fallback]
デフォルト:ForceLanguagePriority Prefer
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_negotiation
互換性:バージョン 2.0.30 以降で使用可能

ForceLanguagePriority ディレクティブは 要求に合うドキュメントを一つだけ返すことができないときに、 LanguagePriority ディレクティブを使ってネゴシエーションの結果を返します。

ForceLanguagePriority Prefer は、同等の選択肢が いくつかあるときに、HTTP の 300 (MULTIPLE CHOICES) を返す代わりに、 LanguagePriority を使って一つだけドキュメントを返すように します。以下のディレクティブが指定されていて、ユーザの Accept-Language ヘッダでは ende の品質が共に .500 (同じくらい許容) であるときは、 最初にマッチする variant の en が送られます。

LanguagePriority en fr de
ForceLanguagePriority Prefer

ForceLanguagePriority Fallback では、HTTP 406 (NOT ACCEPTABLE) を送信する代わりに、 LanguagePriority が正しい結果を送ります。 以下のディレクティブが指定されていて、ユーザの Accept-Languagees 言語のみを許可していて、さらにそのような variant がないときには、 以下の LanguagePriority のリストの最初の variant が送れれます。

LanguagePriority en fr de
ForceLanguagePriority Fallback

PreferFallback の両方のオプションを 同時に指定することができます。 ですから、複数の variant があるときは LanguagePriority の最初の variant が送られ、クライアントの許容言語に合う vaiant がないときは 存在するドキュメントで最初のものが送られる、という様にすることができます。

参照

top

LanguagePriority ディレクティブ

説明:クライアントが優先度を示さなかったときの言語の variant の優先度を 指定
構文:LanguagePriority MIME-lang [MIME-lang] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト, ディレクトリ, .htaccess
上書き:FileInfo
ステータス:Base
モジュール:mod_negotiation

LanguagePriority は、MultiViews リクエストを扱うときに、クライアントが優先順位を提供していない場合の 言語の優先順位を設定します。MIME-lang のリストが優先度の降順に並びます。

Example:

LanguagePriority en fr de

foo.html がリクエストされ、foo.html.frfoo.html.de が両方存在し、 ブラウザが言語の優先順位を提供してない場合は foo.html.fr が返されます。

このディレクティブは他の方法で「最善」 の言語が決定できないときか、ForceLanguagePriority ディレクティブが None 以外のときにのみ効果があることに注意してください。 一般的には、サーバ側ではなくクライアント側で好みの言語を決定します。

参照

mod/mod_nw_ssl.html100644 0 0 14164 11237400230 12034 0ustar 0 0 mod_nw_ssl - Apache HTTP Server
<-

Apache Module mod_nw_ssl

Description:Enable SSL encryption for NetWare
Status:Base
ModuleIdentifier:nwssl_module
SourceFile:mod_nw_ssl.c
Compatibility:NetWare only

Summary

This module enables SSL encryption for a specified port. It takes advantage of the SSL encryption functionality that is built into the NetWare operating system.

top

NWSSLTrustedCerts Directive

Description:List of additional client certificates
Syntax:NWSSLTrustedCerts filename [filename] ...
Context:server config
Status:Base
Module:mod_nw_ssl

Specifies a list of client certificate files (DER format) that are used when creating a proxied SSL connection. Each client certificate used by a server must be listed separately in its own .der file.

top

NWSSLUpgradeable Directive

Description:Allows a connection to be upgraded to an SSL connection upon request
Syntax:NWSSLUpgradeable [IP-address:]portnumber
Context:server config
Status:Base
Module:mod_nw_ssl

Allow a connection that was created on the specified address and/or port to be upgraded to an SSL connection upon request from the client. The address and/or port must have already be defined previously with a Listen directive.

top

SecureListen Directive

Description:Enables SSL encryption for the specified port
Syntax:SecureListen [IP-address:]portnumber Certificate-Name [MUTUAL]
Context:server config
Status:Base
Module:mod_nw_ssl

Specifies the port and the eDirectory based certificate name that will be used to enable SSL encryption. An optional third parameter also enables mutual authentication.

mod/mod_proxy.html100644 0 0 230145 11237400230 11727 0ustar 0 0 mod_proxy - Apache HTTP サーバ
<-

Apache モジュール mod_proxy

This translation may be out of date. Check the English version for recent changes.
説明:HTTP/1.1 プロキシ/ゲートウェイサーバ
ステータス:Extension
モジュール識別子:proxy_module
ソースファイル:mod_proxy.c

概要

警告

サーバを安全にするまで ProxyRequests は有効にしないでください。 オープンプロキシサーバはあなた自身のネットワークにとっても、 インターネット全体にとっても危険です。

このモジュールは Apache のプロキシ/ゲートウェイ機能を実装しています。 AJP13 (Apache JServe Protocol version 1.3), FTP, CONNECT (SSL 用), HTTP/0.9, HTTP/1.0, HTTP/1.1 のプロキシ機能を実装しています。これらのプロトコルやその他のプロトコル用の プロキシ機能を持った、他のモジュールに接続するようにも設定できます。

Apache のプロキシ機能は mod_proxy の他に、 いくつかのモジュールに分割されています: mod_proxy_http, mod_proxy_ftp, mod_proxy_ajp, mod_proxy_balancer, mod_proxy_connect です。ですから、 特定のプロキシの機能を使いたい場合は、mod_proxy 該当するモジュールをサーバに (コンパイル時に静的に行なうか LoadModule で動的に読み込むかして) 組み込む必要があります。

これに加えて、他のモジュールによって拡張機能が提供されています。 キャッシュは mod_cache と関連モジュールで 提供されています。SSL/TLS で遠隔サーバに接続する機能は mod_sslSSLProxy* ディレクティブで 提供されています。これらの機能を利用するためには、該当するモジュールを 組み込んで設定しなければなりません。

top

フォワードプロキシとリバースプロキシ

Apache はフォワードプロキシとしても、 リバースプロキシとしても設定することができます。

通常のフォワードプロキシはクライアントと オリジンサーバ (訳注: コンテンツ生成元のサーバ) の間に位置する中間サーバです。 オリジンサーバからコンテンツを取得する過程では、クライアントは 行き先としてオリジンサーバを指定しつつプロキシにリクエストを送り、 プロキシはオリジンサーバからコンテンツ取得のリクエストを送り、 コンテンツが取得できればそれをクライアントに返します。 クライアントが他のサイトにフォワードプロクシ経由でアクセスするには、 特別にそれ用の設定をしなければなりません。

フォワードプロキシの一般的な使用方法は、ファイアウォールによって 制限されている内部のクライアントにインターネットへのアクセスを 提供するものです。フォワードプロキシはネットワークの使用量を 減らすために (mod_cache で提供されている) キャッシュ機能を用いることもできます。

フォワードプロキシは ProxyRequests ディレクティブで 有効になります。フォワードプロキシでは、クライアントは本当の身元を 隠して任意のサイトにアクセスできるようになるため、フォワードプロキシを 有効にする前に、承認されたクライアントのみがプロキシにアクセスできるように サーバを安全にすることが重要です。

一方リバースプロキシは、クライアントには普通の ウェブサーバのように見えます。クライアント側に特別な設定は必要ありません。 クライアントはリバースプロキシの名前空間に対して通常のコンテンツへの リクエストを行ないます。プロキシはリクエストをどこに送れば良いかを判定し、 あたかも自分自身がオリジンサーバであったかのようにクライアントに コンテンツを返します。

リバースプロキシのよくある利用方法は、インターネットユーザに ファイアウォールの中にあるサーバにアクセスを与えるというものです。 リバースプロキシは複数のバックエンドサーバへ負荷分散をするために 使ったり、遅いバックエンドエンドサーバのためにキャッシュ機能を提供したり するために使えます。また、リバースプロキシは複数のサーバを 同じ URL 空間にまとめるために使うこともできます。

リバースプロキシは ProxyPass ディレクティブや RewriteRule ディレクティブの [P] フラグを使うことで有効になります。リバースプロキシの 設定のために ProxyRequests を設定する必要は ありません

top

基本の例

以下の例は手始めの簡単な例です。個々のディレクティブの意味は それぞれの説明をお読みください。

またキャッシュ機能を有効にしたい場合は、mod_cache の説明を読んでください。

フォワードプロキシ

ProxyRequests On
ProxyVia On

<Proxy *>
Order deny,allow
Deny from all
Allow from internal.example.com
</Proxy>

リバースプロキシ

ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass /foo http://foo.example.com/bar
ProxyPassReverse /foo http://foo.example.com/bar

top

プロキシへのアクセス制御

プロキシのアクセスは以下のように <Proxy> コンテナの中に ディレクティブを書くことで制御できます:

<Proxy *>
Order Deny,Allow
Deny from all
Allow from 192.168.0
</Proxy>

アクセス制御のためのディレクティブのより詳しい情報は mod_authz_host をお読みください。

(ProxyRequests ディレクティブを 使って) フォワードプロキシを設定している場合は、厳しくアクセス 制限を行なうことが非常に大切です。そうしないと、任意のクライアントが 身元を明かすことなく任意のホストにアクセスするためにサーバを使うことが できてしまいます。これはあなた自身のネットワークにとっても、インターネット 全体にとっても危険なことです。(ProxyRequests Off にして ProxyPass ディレクティブを使って) リバースプロキシを使っている場合には、クライアントはあなたが明示的に 設定したホストにしかアクセスできないため、フォワードプロキシのとき ほどアクセス制御に力を注がなくても大丈夫です。

top

遅い起動

ProxyBlock ディレクティブを使っている場合、 後のテストのために起動時にホストの IP アドレスが調べられてキャッシュされます。ホスト名のルックアップの 速さによっては、数秒 (かそれ以上) かかるかもしれません。

top

イントラネットプロキシ

イントラネットにある Apache プロキシサーバは外部へのリクエストを 会社のファイアウォールを通して送らなければなりません。(このためには 個々の scheme についてそれぞれ、ファイアウォールの プロキシにフォワードされるように ProxyRemote ディレクティブを 設定してください)。しかしイントラネット内のリソースにアクセスするときは、 ファイアウォールを通さないでもアクセスできます。 どのホストがイントラネットに属し、直接アクセスすべきかを指定するには、 NoProxy ディレクティブが 役に立ちます。

イントラネット内のユーザは WWW のリクエストでローカルドメインを 省略することがよくあります。http://somehost.example.com/ というリクエストの代わりに "http://somehost/" をリクエストしたりします。 このようなリクエストを受け付け、サーバに設定されているローカルドメインが 暗黙のうちに使われていると解釈して、単純にリクエストを処理するものも 商用プロキシサーバの中にはあります。 サーバが プロキシのサービス用に設定されていて ProxyDomain ディレクティブが 使用された場合には、Apache はクライアントにリダイレクト応答を送って、 正しい、完全な ((訳注: fully qualified)) サーバのアドレスに送ることができます。このように リダイレクトすると、ユーザのブックマークが正しい完全なホスト名を含む ことにもなるため、より好ましい方法と言えるでしょう。

top

プロトコルの調整

Keepalive や HTTP/1.1 を適切に実装していないアプリケーションサーバに対して mod_proxy がリクエストを送信する場合、 HTTP/1.0 を使って keepalive を無しにしてリクエストを送るようにする 環境変数が二つあります。これらは SetEnv ディレクティブで設定します。

force-proxy-request-1.0proxy-nokeepalive がその環境変数です。

<Location /buggyappserver/>
ProxyPass http://buggyappserver:7001/foo/
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
</Location>

top

リクエストボディ

POST メソッドなどのリクエストには、リクエストボディがあります。 HTTP プロトコル仕様によると、ボディのあるリクエストは chunked 転送を使うか、Content-Length ヘッダを送信しなければなりません。 このようなリクエストをオリジンサーバに送信する場合、 mod_proxy_http は常に Content-Length を送ろうと試みます。しかし。ボディが大きく、オリジナルのリクエストで chunked 転送が使われている場合、上流へのリクエストに chunked 転送も使われます。 この挙動は 環境変数で制御できます。 proxy-sendcl を設定すると、可能な限り常に Content-Length を付与して、 上流サーバに送信するようになります。 逆に proxy-sendchunked を設定すると、リソース消費を抑え、 chnked エンコードを使って送信するようになります。

top

AllowCONNECT ディレクティブ

説明:プロキシを経由して、どのポートに CONNECT できるかを指定する
構文:AllowCONNECT port [port] ...
デフォルト:AllowCONNECT 443 563
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_proxy

AllowCONNECT はプロキシの CONNECT メソッドが接続を許可するポート番号のリストを指定します。 今日のブラウザは、https コネクションが要求されていて、 HTTP 上でのプロキシによるトンネリングができるときに、 このメソッドを使います。

デフォルトの設定では、https のデフォルトポート (443) と デフォルトの snews ポート (563) が有効になっています。 このデフォルトを上書きして、リストに記載したポートにのみ接続を許可したい場合、 AllowCONNECT ディレクティブを使用します。

CONNECT を使用するには、mod_proxy_connect がサーバに組み込まれていなければならないことに注意してください。

top

NoProxy ディレクティブ

説明:直接接続する ホスト、ドメイン、ネットワーク
構文:NoProxy host [host] ...
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_proxy

このディレクティブはイントラネット中の Apache プロキシサーバにのみ 有用です。NoProxy ディレクティブは空白区切りで、 サブネット、IP アドレス、ホスト、ドメインのリストを指定します。 これらのどれかにマッチするホストへのリクエストは ProxyRemote で設定されたプロキシサーバに フォワードされず、直接処理されます。

ProxyRemote * http://firewall.mycompany.com:81
NoProxy .mycompany.com 192.168.112.0/21

NoProxy ディレクティブの host 引数は 以下の種類のどれかです:

Domain

Domain は先頭にピリオドの着いた部分 DNS ドメイン名です。 同一 DNS ドメイン及びゾーン (すなわち、ホスト名の末尾がすべて Domain で終わっているということ) に属するホストのリストを 表します)。

.com .apache.org.

DomainHostname と区別するために (意味的にも構文的にも。DNS ドメインも DNS の A レコードを持つことができるのです!)、Domain は 常にピリオドで始まります。

ドメイン名の比較は大文字小文字を区別せずに行なわれ、Domain は常に DNS ツリーのルートから始まるものとみなされます。ですから、 次の二つのドメイン .MyDomain.com.mydomain.com. (最後のピリオドに注目) は同一であると みなされます。ドメインの比較は DNS ルックアップなしで行なわれるため、 サブネットの比較よりもずっと効率的です。

SubNet

SubNet は数値形式 (ドットで区切られた四つの数字) の 部分インターネットアドレスです。後にスラッシュと Subnet の意味のあるビット数を指定するネットマスクとを続けることができます。 共通のネットワークインタフェースを使って到達することのできるサブネットを 表すために使われます。明示的にネットマスクを指定しない場合は 最後の省略された (もしくは値が 0 の) 数字がマスクを指定します。 (この場合は、ネットマスクは 8 ビット単位でしか指定できません。) 例:

192.168 もしくは 192.168.0.0
サブネット 192.168.0.0 と暗黙の 16 ビット有効なネットマスク (255.255.0.0 というネットマスクの形式で使われることも あります)
192.168.112.0/21
サブネット192.168.112.0/21 と 21 ビット有効な ネットマスク (255.255.248.0 という形式で使われることも あります)

特別な場合に、32 ビット有効な SubNetIPAddr と同等で、 0 ビット有効な SubNet (例えば、0.0.0.0/0) は すべての IP アドレスにマッチする定数 _Default_ と同じです。

IPAddr

IPAddr は数値形式 (ドットで区切られた四つの数字) の 完全インターネットアドレスです。通常はこのアドレスはホストを 表しますが、必ずしもアドレスに対応する DNS ドメイン名があるわけでは ありません。

192.168.123.7

IPAddr は DNS システムにより解決される必要がないので、 apache の性能が向上するかもしれません。

Hostname

Hostname は DNS ドメインサービスにより一つもしくは 複数の IPAddr に解決可能な 完全な DNS ドメイン名です。これは (Domain と違って、説明は上記を参照) 論理的なホストを表し、少くとも一つの IPAddr (もしくは違う IPAddr のホストのリスト) に解決 されなければなりません)。

prep.ai.mit.edu
www.apache.org

多くの場合、Hostname の代わりに IPAddr を指定した方が、DNS ルックアップを 避けることができるため、効率が良くなります。Apache の名前解決は ネームサーバへの接続が遅い PPP 上の場合などにかなり時間を取られる ことがあります。

Hostname の比較は大文字小文字を区別せずに行なわれ、 Hostname は常に DNS ツリーのルートから始まるものとみなされます。 ですから、二つのドメイン WWW.MyDomain.comwww.mydomain.com. (最後のピリオドに注目) は同一であると みなされます。

参照

top

<Proxy> ディレクティブ

説明:プロキシされるリソースに適用されるコンテナ
構文:<Proxy wildcard-url> ...</Proxy>
コンテキスト:サーバ設定ファイル, バーチャルホスト
ステータス:Extension
モジュール:mod_proxy

<Proxy> セクション中の ディレクティブはマッチするプロキシされるコンテンツにのみ適用されます。 シェル形式のワイルドカードが使えます。

例えば、次の設定は yournetwork.example.com の ホストにのみプロキシサーバを経由したアクセスを許可します:

<Proxy *>
Order Deny,Allow
Deny from all
Allow from yournetwork.example.com
</Proxy>

次の例は