]> granicus.if.org Git - apache/blob - docs/manual/env.xml.ja
Convert Japanese translations from ISO-2022-JP to UTF-8
[apache] / docs / manual / env.xml.ja
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
3 <?xml-stylesheet type="text/xsl" href="./style/manual.ja.xsl"?>
4 <!-- English Revision: 420990:659902 (outdated) -->
5
6 <!--
7  Licensed to the Apache Software Foundation (ASF) under one or more
8  contributor license agreements.  See the NOTICE file distributed with
9  this work for additional information regarding copyright ownership.
10  The ASF licenses this file to You under the Apache License, Version 2.0
11  (the "License"); you may not use this file except in compliance with
12  the License.  You may obtain a copy of the License at
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
16  Unless required by applicable law or agreed to in writing, software
17  distributed under the License is distributed on an "AS IS" BASIS,
18  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and
20  limitations under the License.
21 -->
22
23 <manualpage metafile="env.xml.meta">
24
25   <title>Apache の環境変数</title>
26
27   <summary>
28     <p>Apache HTTP サーバは<em>環境変数</em>と呼ばれる、名前のついた
29     変数に情報を記憶する仕組みを提供しています。この情報はログ収集や
30     アクセス制御などのいろいろな操作を制御するために使うことができます。
31     これらの変数は CGI スクリプトなどの外部プログラムと通信するためにも
32     使われます。この文書はそれらの変数の操作方法と使用方法をいくつか
33     紹介します。</p>
34
35     <p>これらの変数は<em>環境変数</em>と呼ばれていますが、オペレーティング
36     システムによって制御されている環境変数と同じではありません。
37     実際は、これらの変数は Apache の内部構造の中に記憶され、操作されています。
38     それらは、CGI や SSI スクリプトに渡されたときだけ、実際の
39     オペレーティングシステムの環境変数になります。サーバ自身が
40     実行されているオペレーティングシステムの環境を操作したい場合は、
41     オペレーティングシステムのシェルが提供している標準の環境変数の
42     操作方法を使わなければなりません。</p>
43   </summary>
44
45   <section id="setting">
46     <title>環境変数の設定</title>
47     <related>
48       <modulelist>
49         <module>mod_env</module>
50         <module>mod_rewrite</module>
51         <module>mod_setenvif</module>
52         <module>mod_unique_id</module>
53       </modulelist>
54       <directivelist>
55         <directive module="mod_setenvif">BrowserMatch</directive>
56         <directive module="mod_setenvif">BrowserMatchNoCase</directive>
57         <directive module="mod_env">PassEnv</directive>
58         <directive module="mod_rewrite">RewriteRule</directive>
59         <directive module="mod_env">SetEnv</directive>
60         <directive module="mod_setenvif">SetEnvIf</directive>
61         <directive module="mod_setenvif">SetEnvIfNoCase</directive>
62         <directive module="mod_env">UnsetEnv</directive>
63       </directivelist>
64     </related>
65
66     <section id="basic-manipulation">
67         <title>基本的な環境の操作</title>
68
69         <p>Apache において環境変数を設定する一番基本的な方法は、
70         無条件に環境変数を設定する <directive module="mod_env"
71         >SetEnv</directive> ディレクティブを使用することです。
72         <directive module="mod_env">PassEnv</directive> 
73         ディレクティブにより、Apache が起動されたシェルの
74         環境変数を渡すこともできます。</p>
75
76     </section>
77     <section id="conditional">
78         <title>リクエスト毎に条件に基づいて設定する</title>
79
80         <p>より柔軟性を高めるために、mod_setenvif
81         で提供されているディレクティブを使用することで、リクエストの
82         特性に基づいて環境変数を設定することができます。例えば、特定のブラウザ
83         (User-Agent) のリクエストや特定の Referer [意図的な綴りです]
84         (訳注: 正しい綴りは referrer ですが、HTTP の仕様では Referer
85         となっています) ヘッダが見つかったときのみ変数を設定することができます。
86         mod_rewrite の <directive module="mod_rewrite">RewriteRule</directive>
87         ディレクティブにおいて環境変数を設定する <code>[E=...]</code>
88         オプションを使用することで、
89         より柔軟な設定を行なうことができます。</p>
90
91     </section>
92     <section id="unique-identifiers">
93         <title>一意な識別子</title>
94
95         <p>mod_unique_id は、非常に限られた条件の下で
96         「すべて」のリクエストについて、一意であることが保証されている値を環境変数
97         <code>UNIQUE_ID</code> に設定します。</p>
98
99     </section>
100     <section id="standard-cgi">
101         <title>標準 CGI 変数</title>
102
103         <p>Apache の設定ファイルで設定された環境変数とシェルから渡される
104         環境変数に加えて、CGI スクリプトと SSI ページには <a
105         href="http://cgi-spec.golux.com">CGI の仕様</a>で要求されている、
106         リクエストのメタ情報を持った環境変数の組が提供されます。</p>
107
108     </section>
109     <section id="caveats">
110         <title>いくつかの注意</title>
111
112         <ul>
113           <li>環境を操作するディレクティブを使って標準 CGI
114           変数を上書きしたり変更したりすることはできません。</li>
115
116           <li>CGI スクリプトを起動するために <program>suexec</program>
117           が使用されている場合、CGI スクリプトが起動するために、環境変数は<em
118           >安全</em>な環境変数の組に整理されます。
119           この安全な環境変数の集合は、コンパイル時に <code>suexec.c</code>
120           で定義されます。</li>
121
122           <li>移植性のために、環境変数の名前はアルファベット、
123           数字とアンダースコア (訳注: '_') だけから成ります。
124           さらに、最初の文字は数字であってはいけません。
125           この制限に合わない文字は CGI スクリプトと SSI
126           ページに渡されるときにアンダースコアに置換されます。</li>
127         </ul>
128     </section>
129   </section>
130   <section id="using">
131     <title>環境変数の使用</title>
132
133     <related>
134       <modulelist>
135         <module>mod_authz_host</module>
136         <module>mod_cgi</module>
137         <module>mod_ext_filter</module>
138         <module>mod_headers</module>
139         <module>mod_include</module>
140         <module>mod_log_config</module>
141         <module>mod_rewrite</module>
142       </modulelist>
143       <directivelist>
144         <directive module="mod_authz_host">Allow</directive>
145         <directive module="mod_log_config">CustomLog</directive>
146         <directive module="mod_authz_host">Deny</directive>
147         <directive module="mod_ext_filter">ExtFilterDefine</directive>
148         <directive module="mod_headers">Header</directive>
149         <directive module="mod_log_config">LogFormat</directive>
150         <directive module="mod_rewrite">RewriteCond</directive>
151         <directive module="mod_rewrite">RewriteRule</directive>
152       </directivelist>
153     </related>
154
155     <section id="cgi-scripts">
156         <title>CGI スクリプト</title>
157
158         <p>環境変数の主な利用法の一つは、CGI スクリプトに情報を伝えることです。
159         上で説明されているように、CGI スクリプトに渡される環境変数は Apache
160         の設定により設定される変数に加えて、リクエストの標準のメタ情報を含んでいます。
161         詳細は <a href="howto/cgi.html">CGI チュートリアル</a>
162         を参照してください。</p>
163
164     </section>
165     <section id="ssi-pages">
166         <title>SSI ページ</title>
167
168         <p>mod_include の <code>INCLUDES</code> フィルタで処理される
169         server-parsed (SSI) ドキュメントでは、<code>echo</code>
170         要素を使用すると環境変数が出力されます。
171         また、ページのある部分がリクエストの性質に応じて変更されるように、
172         環境変数をフロー制御要素で使うことができます。詳細は
173         <a href="howto/ssi.html">SSI チュートリアル</a> を参照してください。</p>
174
175     </section>
176     <section id="access-control">
177         <title>アクセス制御</title>
178
179         <p><code>allow from env=</code> ディレクティブと <code>deny from env=</code>
180         ディレクティブを使用して、サーバへのアクセスを環境変数の値で制御することができます。
181         <directive module="mod_setenvif">SetEnvIf</directive>
182         ディレクティブと組み合わせることで、クライアントの特性に基づいて
183         サーバへのアクセス制御を柔軟に行なうことができるようになります。
184         たとえば、これらのディレクティブを使用して、特定のブラウザ (User-Agent)
185         からのアクセスを拒否することができます。</p>
186
187     </section>
188     <section id="logging">
189         <title>条件付きログ記録</title>
190
191         <p><directive module="mod_log_config">LogFormat</directive>
192         ディレクティブのオプション <code>%e</code>
193         を使用することで、環境変数をアクセスログに記録することができます。さらに、
194         <directive module="mod_log_config">CustomLog</directive>
195         ディレクティブの条件分岐式を使用することで、
196         環境変数の値によってリクエストをログに記録するかどうかを決めることができます。
197         <directive module="mod_setenvif">SetEnvIf</directive>
198         ディレクティブと組み合わせることで、
199         どのリクエストをログに記録するかを柔軟に制御することが可能になります。たとえば、
200         <code>gif</code> で終わるファイル名へのリクエストはログに記録しない、
201         違うサブネットのクライアントからのリクエストだけをログに記録する、
202         という選択が可能です。</p>
203
204     </section>
205     <section id="response-headers">
206         <title>条件付き応答ヘッダ</title>
207
208         <p><directive module="mod_headers">Header</directive>
209         ディレクティブは環境変数の存在や不在によってクライアントへの応答に特定の
210         HTTP ヘッダを付けるかどうかを決めることができます。
211         これにより、たとえば、クライアントからのリクエスト
212         にあるヘッダがある場合にのみ特定の応答ヘッダを送る、というようなことが
213         できます。</p>
214
215     </section>
216
217     <section id="external-filter">
218         <title>外部フィルタの適用</title>
219
220         <p><directive module="mod_ext_filter">ExtFilterDefine</directive>
221         ディレクティブを使用して
222         <module>mod_ext_filter</module> で設定される外部フィルタは、
223         <code>disableenv=</code> と <code>enableenv=</code>
224         オプションを使って、環境変数による条件付き適用ができます。</p>
225     </section>
226
227     <section id="url-rewriting">
228         <title>URL の書き換え</title>
229
230         <p><directive module="mod_rewrite">RewriteCond</directive>
231         ディレクティブで<em>評価文字列</em>として
232         <code>%{ENV:...}</code> 式を指定することで、mod_rewrite
233         の書き換えエンジンが環境変数に基いて条件分岐を行なうことができます。
234         mod_rewrite が使用可能な変数で <code>ENV:</code> が前についていない変数は、
235         実際は環境変数ではないということに注意してください。
236         それらは他のモジュールからは使用できない mod_rewrite 用の特別な変数です。
237         </p>
238     </section>
239   </section>
240
241   <section id="special">
242     <title>特別な目的の環境変数</title>
243
244         <p>互換性の問題を解決するために、特定のクライアントと通信しているときは
245         Apache の動作を変更できる機構が導入されました。できるだけ柔軟にするために、
246         これらの機構は環境変数を定義することで呼び出されます。普通は、
247         <directive module="mod_setenvif">BrowserMatch</directive>
248         ディレクティブを使いますが、たとえば <directive module="mod_env"
249         >SetEnv</directive> ディレクティブや <directive module="mod_env"
250         >PassEnv</directive> ディレクティブも使用することができます。</p>
251
252     <section id="downgrade">
253         <title>downgrade-1.0</title>
254
255         <p>これを指定することで、リクエストが HTTP/1.0
256         より新しいプロトコルの場合でも、HTTP/1.0 として扱われます。</p>
257
258     </section>
259     <section id="force-gzip">
260         <title>force-gzip</title>
261           <p><code>DEFLATE</code> フィルタが使用するように設定されているときに、
262           この環境変数はブラウザの accept-encoding の設定を無視して常に
263           圧縮された出力を送るようにします。</p>
264     </section>
265     <section id="force-no-vary">
266         <title>force-no-vary</title>
267
268         <p>応答ヘッダがクライアントに送られる前に <code>Vary</code>
269         フィールドを取り除きます。
270         クライアントの中にはこのフィールドを正しく解釈しないものがあります。
271         この変数を設定することでその問題を回避することができます。
272         この変数を設定すると、<strong>force-response-1.0</strong>
273         が設定されたことになります。</p>
274
275     </section>
276     <section id="force-response">
277         <title>force-response-1.0</title>
278
279         <p>これが設定されていると、HTTP/1.0 リクエストを発行するクライアントに対しては
280         常に HTTP/1.0 で応答するようになります。この機能は、
281         元々は AOL のプロキシの問題のために実装されました。HTTP/1.0 クライアントの中には、
282         HTTP/1.1 の応答を返されると正しく動作しないものがあるかもしれません。
283         この機能を使用することで、そのようなクライアントとの間の互換性問題を解決できます。</p>
284     </section>
285
286     <section id="gzip-only-text-html">
287         <title>gzip-only-text/html</title>
288
289         <p>これが 1 に設定されると、この変数は <code>text/html</code>
290         以外のコンテントタイプに対する、<module>mod_deflate</module>
291         提供の <code>DEFLATE</code> 出力フィルタを無効にします。
292         また、静的に、既に圧縮されたファイルを使用したい場合、
293         (gzip だけでなく、"identity" と異なる全てのエンコードに対して)
294         <module>mod_negotiation</module> も変数を評価します。</p>
295     </section>
296
297     <section id="no-gzip"><title>no-gzip</title>
298         <p>セットされると、<module>mod_deflate</module> の
299         <code>DEFLATE</code> フィルタがオフになります。
300         そして <module>mod_negotiation</module>
301         はエンコードされたリソースを送らないようにします。</p>
302     </section>
303
304     <section id="nokeepalive">
305         <title>nokeepalive</title>
306
307         <p>これが設定されている場合は、<directive module="core"
308         >KeepAlive</directive> を使用しないようにします。</p>
309
310     <section id="prefer-language"><title>prefer-language</title>
311
312         <p><module>mod_negotiation</module> の挙動に影響を与えます。
313         (<code>en</code>, <code>ja</code>, <code>x-klingon</code>といった)
314         言語タグが格納されていれば、その言語の variant を送信しようとします。
315         そのような variant がない場合は、
316         通常の<a href="content-negotiation.html">ネゴシエーション</a>処理が
317         適用されます。</p>
318
319     </section>
320
321     </section>
322     <section id="redirect-carefully">
323         <title>redirect-carefully</title>
324
325         <p>これはクライアントへのリダイレクトの送信をサーバがより注意深く
326         行なうようにします。
327         これは通常、リダイレクトに際してクライアントに
328         問題があることが分かっている場合に使われます。この機能は元々は
329         マイクロソフトのウェブフォルダのソフトが DAV
330         メソッドによるディレクトリのリソースへのリダイレクトの扱いに
331         問題がり、それを回避するために実装されました。</p>
332
333     </section>
334
335    <section id="suppress-error-charset">
336        <title>suppress-error-charset</title>
337
338     <p><em>Apache 2.2 以降で利用可能</em></p>
339
340     <p>クライアントのリクエストに対する応答としてリダイレクトを送信する際、
341     レスポンスにはリダイレクトが自動的に行なえない (行なわれない)
342     場合に表示するテキストが含まれます。
343     通常、このテキストに合致したキャラクタセット、ISO-8859-1
344     でラベル付けをします。</p>
345     <p>しかし、リダイレクト先が別の文字セットを使っている場合、
346     ある問題のあるブラウザのバージョンでは、
347     リダイレクト先の実際の文字セットの代わりに、
348     リダイレクト元の文字セットを使ってしまうことがあります。
349     その結果、例えば変な描画が行なわれたりして、読めなくなったりします。</p>
350     <p>この環境変数を設定することで、リダイレクションテキストに対する
351     キャラクタセットの指定を除去しますので、それら問題のあるブラウザでも
352     リダイレクト先の文字セットを正しく使うようにできます。</p>
353
354    </section>
355
356    <section id="proxy"><title>force-proxy-request-1.0, proxy-nokeepalive, proxy-sendchunked, proxy-sendcl</title>
357
358    <p>これらの指示子は <module>mod_proxy</module> の挙動を変更します。
359    詳細は <module>mod_proxy</module> のドキュメントをご参照ください。</p>
360    </section>
361
362   </section>
363
364   <section id="examples">
365     <title>例</title>
366
367     <section id="misbehaving">
368         <title>おかしな挙動をするクライアントに対してプロトコルの動作を変更する</title>
369
370         <p>クライアントに関する既知の問題に対処するために、以下の行を
371         httpd.conf に入れることを推奨しています。</p>
372         <p>古いバージョンの Apache では、クライアントの問題に対応するために
373         httpd.conf に次の行を加えるよう推奨されていましたが、
374         今となっては、問題としていたクライアントは実際には見かけることは
375         なくなってきたので、この設定はもはや必要ないかもしれません。</p>
376 <example><pre>
377 #
378 # The following directives modify normal HTTP response behavior.
379 # The first directive disables keepalive for Netscape 2.x and browsers that
380 # spoof it. There are known problems with these browser implementations.
381 # The second directive is for Microsoft Internet Explorer 4.0b2
382 # which has a broken HTTP/1.1 implementation and does not properly
383 # support keepalive when it is used on 301 or 302 (redirect) responses.
384 #
385 BrowserMatch "Mozilla/2" nokeepalive
386 BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
387
388 #
389 # The following directive disables HTTP/1.1 responses to browsers which
390 # are in violation of the HTTP/1.0 spec by not being able to grok a
391 # basic 1.1 response.
392 #
393 BrowserMatch "RealPlayer 4\.0" force-response-1.0
394 BrowserMatch "Java/1\.0" force-response-1.0
395 BrowserMatch "JDK/1\.0" force-response-1.0</pre></example>
396
397     </section>
398     <section id="no-img-log">
399         <title>画像へのリクエストをアクセスログに記録しない</title>
400
401         <p>この例では、画像へのリクエストがアクセスログに現れないようにします。
402         これを変更することで、特定のディレクトリのログ収集をやめたり、
403         特定のホストからのリクエストのログ収集をやめたりすることが簡単にできます。
404         </p>
405     <example><pre>
406 SetEnvIf Request_URI \.gif image-request
407 SetEnvIf Request_URI \.jpg image-request
408 SetEnvIf Request_URI \.png image-request
409 CustomLog logs/access_log common env=!image-request</pre></example>
410
411     </section>
412     <section id="image-theft">
413         <title>「画像の盗用」を防ぐ</title>
414
415         <p>この例は、別のサーバにいる人が、あなたのサーバにある画像を
416         inline 画像として使用することを防ぎます。
417         これは推奨されている設定ではありませんが、ある限定された状況では有効です。
418         ここでは、すべての画像は <code>/web/images</code>
419         というディレクトリにあると仮定します。</p>
420     <example><pre>
421 SetEnvIf Referer "^http://www\.example\.com/" local_referal
422 # Allow browsers that do not send Referer info
423 SetEnvIf Referer "^$" local_referal
424 &lt;Directory /web/images&gt;
425    Order Deny,Allow
426    Deny from all
427    Allow from env=local_referal
428 &lt;/Directory&gt;</pre></example>
429
430         <p>この手法に関する詳しい情報は ApacheToday のチュートリアル「<a
431         href="http://apachetoday.com/news_story.php3?ltsn=2000-06-14-002-01-ps"
432         >Keeping Your Images from Adorning Other Sites</a>
433         」を参照してください。</p>
434     </section>
435   </section>
436 </manualpage>