github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_2_34/manual/vhosts/name-based.html.ja.utf8 (about) 1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 3 <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"><head> 4 <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> 5 <!-- 6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 7 This file is generated from xml source: DO NOT EDIT 8 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 9 --> 10 <title>名前ベースのバーチャルホスト - Apache HTTP サーバ バージョン 2.2</title> 11 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> 12 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> 13 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> 14 <script src="../style/scripts/prettify.min.js" type="text/javascript"> 15 </script> 16 17 <link href="../images/favicon.ico" rel="shortcut icon" /><link href="http://httpd.apache.org/docs/current/vhosts/name-based.html" rel="canonical" /></head> 18 <body id="manual-page"><div id="page-header"> 19 <p class="menu"><a href="../mod/">モジュール</a> | <a href="../mod/directives.html">ディレクティブ</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">用語</a> | <a href="../sitemap.html">サイトマップ</a></p> 20 <p class="apache">Apache HTTP サーバ バージョン 2.2</p> 21 <img alt="" src="../images/feather.gif" /></div> 22 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> 23 <div id="path"> 24 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP サーバ</a> > <a href="http://httpd.apache.org/docs/">ドキュメンテーション</a> > <a href="../">バージョン 2.2</a> > <a href="./">バーチャルホスト</a></div><div id="page-content"><div class="retired"><h4>Please note</h4> 25 <p> This document refers to a legacy release (<strong>2.2</strong>) of Apache httpd. The active release (<strong>2.4</strong>) is documented <a href="http://httpd.apache.org/docs/current">here</a>. If you have not already upgraded, please follow <a href="http://httpd.apache.org/docs/current/upgrading.html">this link</a> for more information.</p> 26 <p>You may follow <a href="http://httpd.apache.org/docs/current/vhosts/name-based.html">this link</a> to go to the current version of this document.</p></div><div id="preamble"><h1>名前ベースのバーチャルホスト</h1> 27 <div class="toplang"> 28 <p><span>翻訳済み言語: </span><a href="../de/vhosts/name-based.html" hreflang="de" rel="alternate" title="Deutsch"> de </a> | 29 <a href="../en/vhosts/name-based.html" hreflang="en" rel="alternate" title="English"> en </a> | 30 <a href="../fr/vhosts/name-based.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | 31 <a href="../ja/vhosts/name-based.html" title="Japanese"> ja </a> | 32 <a href="../ko/vhosts/name-based.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | 33 <a href="../tr/vhosts/name-based.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> 34 </div> 35 <div class="outofdate">この日本語訳はすでに古くなっている 36 可能性があります。 37 最近更新された内容を見るには英語版をご覧下さい。 38 </div> 39 40 <p>この文書では名前ベースのバーチャルホストをどんなとき、 41 どうやって使うかを説明します。</p> 42 </div> 43 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#namevip">名前ベースと IP ベースのバーチャルホストの比較</a></li> 44 <li><img alt="" src="../images/down.gif" /> <a href="#using">名前ベースのバーチャルホストを利用する</a></li> 45 <li><img alt="" src="../images/down.gif" /> <a href="#compat">古いブラウザとの互換性</a></li> 46 </ul><h3>参照</h3><ul class="seealso"><li><a href="ip-based.html">ネームベースのバーチャルホスト</a></li><li><a href="details.html">バーチャルホストのマッチングについての詳細</a></li><li><a href="mass.html">大量のバーチャルホストの動的な設定</a></li><li><a href="examples.html">バーチャルホストの一般的な設定例</a></li><li><a href="examples.html#serverpath">ServerPath 設定例</a></li></ul><ul class="seealso"><li><a href="#comments_section">コメント</a></li></ul></div> 47 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 48 <div class="section"> 49 <h2><a name="namevip" id="namevip">名前ベースと IP ベースのバーチャルホストの比較</a></h2> 50 51 <p>IP ベースのバーチャルホストでは、応答する 52 バーチャルホストへのコネクションを決定するために IP 53 アドレスを使用します。ですから、それぞれのホストに個々に IP 54 アドレスが必要になります。これに対して名前ベースのバーチャルホストでは、 55 クライアントが HTTP ヘッダの一部としてホスト名を告げる、 56 ということに依存します。この技術で同一 IP 57 アドレスを異なる多数のホストで共有しています。</p> 58 59 <p>名前ベースのバーチャルホストは通常単純で、それぞれのホスト名と 60 それに対応する正確な IP アドレスを DNS で設定し、異なる 61 ホスト名を区別するように Apache HTTP サーバを設定するだけです。 62 さらに、名前ベースのバーチャルホストは不足する IP 63 アドレスの需要を緩和します。したがって、IP ベースのバーチャルホストを 64 選択すべき特定の理由がなければ名前ベースのバーチャルホストを使うべきです。 65 IP ベースのバーチャルホストを使用することを考慮する理由として、</p> 66 67 <ul> 68 <li>名前ベースのバーチャルホストに対応していない古いクライアントがある 69 名前ベースのバーチャルホストが働くためには、クライアントは 70 HTTP ホストヘッダを送ってこなければなりません。 71 これは HTTP/1.1 の仕様で要求されていて、すべての現代的な 72 HTTP/1.0 ブラウザでも拡張として実装されています。 73 とても古いクライアントをサポートしつつ、名前ベースの 74 バーチャルホストを行いたい場合は、この文書の最後の方に 75 書かれている解決策になるかもしれない方法を見てください。</li> 76 77 <li>名前ベースのバーチャルホストは SSL プロトコルの特徴により、 78 SSL セキュアサーバには使えません。</li> 79 80 <li>オペレーティングシステムやネットワーク装置のなかには、 81 別の IP アドレス上でない場合、複数のホストを別扱いできないような 82 帯域管理の方法を実装しているものがあります。</li> 83 </ul> 84 85 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 86 <div class="section"> 87 <h2><a name="using" id="using">名前ベースのバーチャルホストを利用する</a></h2> 88 89 <table class="related"><tr><th>関連モジュール</th><th>関連ディレクティブ</th></tr><tr><td><ul><li><code class="module"><a href="../mod/core.html">core</a></code></li></ul></td><td><ul><li><code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code></li><li><code class="directive"><a href="../mod/core.html#namevirtualhost">NameVirtualHost</a></code></li><li><code class="directive"><a href="../mod/core.html#serveralias">ServerAlias</a></code></li><li><code class="directive"><a href="../mod/core.html#servername">ServerName</a></code></li><li><code class="directive"><a href="../mod/core.html#serverpath">ServerPath</a></code></li><li><code class="directive"><a href="../mod/core.html#virtualhost">VirtualHost</a></code></li><li><code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code></li></ul></td></tr></table> 90 91 <p>名前ベースのバーチャルホストを使うには、そのホストへの 92 リクエストを受け付けるサーバの IP アドレス (もしかしたらポートも) 93 を指定する必要があります。 94 これは <code class="directive"><a href="../mod/core.html#namevirtualhost">NameVirtualHost</a></code> 95 ディレクティブで設定します。通常、<code class="directive"><a href="../mod/core.html#namevirtualhost">NameVirtualHost</a></code> で 96 <code>*</code> の属性を使ってサーバの全ての IP アドレスを使います。 97 (例えば SSL の使用などで) 複数のポートを使うことを計画しているのであれば、 98 引数に <code>*:80</code> のようにポートも含めるようにしてください。 99 <code class="directive"><a href="../mod/core.html#namevirtualhost">NameVirtualHost</a></code> ディレクティブで 100 IP アドレスを書いても、 101 自動的にサーバがその IP アドレスをリッスンするということはないことに 102 注意してください。詳細は「<a href="../bind.html">Apache の使うアドレスと 103 ポートを設定する</a>」を読んでください。さらに、ここで指定された 104 IP アドレスは全てサーバのネットワークインターフェースと関連付けられて 105 いなければなりません。</p> 106 107 <p>次は、扱うホストそれぞれに対して <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> ブロックを 108 作成してください。<code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> 109 ディレクティブの引数は <code class="directive"><a href="../mod/core.html#namevirtualhost">NameVirtualHost</a></code> 110 ディレクティブの引数と同じにしてください (すなわち、IP アドレスか、全てのアドレスを意味する 111 <code>*</code>)。それぞれの <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> 112 ディレクティブの中には、最低限、どのホストが扱われるかを示す <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code> ディレクティブと、 113 そのホスト用のコンテンツがファイルシステム上のどこにあるかを示す 114 <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> ディレクティブを 115 書く必要があります。</p> 116 117 <div class="note"><h3>メインホストはなくなります</h3> 118 <p>既にあるウェブサーバにバーチャルホストを追加する場合、 119 既存のウェブサーバに対しても <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> 120 ブロックを作らなければなりません。このバーチャルホストの 121 <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code> と 122 <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> 123 は、グローバルな <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code> と 124 <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> 125 と同じものにします。また、このバーチャルホストを設定ファイルの中で 126 先頭に置いて、デフォルトホストとして動作するようにします。</p> 127 </div> 128 129 <p>たとえば、<code>www.domain.tld</code> を動かしていて、 130 さらにバーチャルホスト <code>www.otherdomain.tld</code> 131 を追加するとしましょう。このバーチャルホストは同一 IP を指しているとします。 132 そのような場合は、<code>httpd.conf</code> 133 に以下のようなコードを追加するだけです</p> 134 135 <div class="example"><p><code> 136 NameVirtualHost *:80<br /> 137 <br /> 138 <VirtualHost *:80><br /> 139 <span class="indent"> 140 ServerName www.domain.tld<br /> 141 ServerAlias domain.tld *.domain.tld<br /> 142 DocumentRoot /www/domain<br /> 143 </span> 144 </VirtualHost><br /> 145 <br /> 146 <VirtualHost *:80><br /> 147 <span class="indent">ServerName www.otherdomain.tld<br /> 148 DocumentRoot /www/otherdomain<br /> 149 </span> 150 </VirtualHost><br /> 151 </code></p></div> 152 153 <p><code class="directive"><a href="../mod/core.html#namevirtualhost">NameVirtualHost</a></code> 及び 154 <code class="directive"><a href="../mod/core.html#virtualhost">VirtualHost</a></code> のどちらの場合も、 155 * の部分には明示的に IP アドレスを指定することができます。 156 例えば、ある IP アドレスでは名前ベースのバーチャルホストを使いたい一方で、 157 別の IP アドレスでは、他の IP ベースのバーチャルホストや 158 別組の名前ベースのバーチャルホストを使いたい場合、 159 そう設定することになるでしょう。</p> 160 161 <p>複数の名前でサーバアクセスができるようにしたいことも多いでしょう。 162 このようなことは、<code class="directive"><a href="../mod/core.html#serveralias">ServerAlias</a></code> ディレクティブを <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> 163 セクションに記述することで実現できます。 164 例えば上記の <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> の例であれば、 165 次のように一覧に挙げられた名前が、 166 ユーザが同一のウェブサイトとして目にして使用できるサーバ名である、 167 と <code class="directive"><a href="../mod/core.html#serveralias">ServerAlias</a></code> 168 ディレクティブで指定できます。</p> 169 170 <div class="example"><p><code> 171 ServerAlias domain.tld *.domain.tld 172 </code></p></div> 173 174 <p><code>domain.tld</code> ドメインへの全てのホストへのリクエストは 175 <code>www.domain.tld</code> のバーチャルホストが処理します。 176 名前をマッチさせるために、ワイルドカード文字 * や ? 177 を使用することもできます。もちろん思いつきの名前を作って、 178 <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code> や 179 <code class="directive"><a href="../mod/core.html#serveralias">ServerAlias</a></code> 180 にその名前を書くといったことはできません。まずは、 181 これらの名前が サーバに付けられた IP アドレスにマップされるように 182 DNS サーバを適切に設定しなければなりません。</p> 183 184 <p>最後に、<code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> コンテナの中に 185 他のディレクティブを書くことで、バーチャルホストの設定を細かく調整 186 することができます。 187 ほとんどのディレクティブはこれらのコンテナに設置することができて、 188 変更点はそのバーチャルホストに対してのみ有効になります。 189 どのディレクティブを書くことができるかは、ディレクティブの <a href="../mod/directive-dist.html#context">コンテキスト</a> を 190 調べてください。<em>主サーバコンテキスト</em> 191 (<code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> 192 コンテナの外) の設定用ディレクティブはバーチャルホストでの設定で 193 上書きされない場合のみ使用されます。</p> 194 195 <p>リクエストが来ると、サーバはまず最初に <code class="directive"><a href="../mod/core.html#namevirtualhost"><NameVirtualHost></a></code> 196 にマッチする IP アドレスかどうかをチェックします。マッチすれば 197 マッチした IP アドレスの <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> 198 のそれぞれのセクションの中から 199 <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code> か 200 <code class="directive"><a href="../mod/core.html#serveralias">ServerAlias</a></code> 201 に要求されたホスト名があるか探します。 202 見つかればそのサーバ用の設定を使います。マッチするバーチャルホスト 203 が見つからなければ、マッチした IP アドレスの 204 <strong>リストの最初にあるバーチャルホスト</strong> が使われます。</p> 205 206 <p>結果として、リストの最初のバーチャルホストが <em>デフォルト</em> の 207 バーチャルホストになります。IP アドレスが <code class="directive"><a href="../mod/core.html#namevirtualhost">NameVirtualHost</a></code> 208 ディレクティブにマッチした場合は、<em>メインのサーバ</em> の 209 <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> 210 は<strong>決して使われません</strong> 211 どのバーチャルホストにもマッチしないリクエストに対して、 212 特別な設定をしたいのであれば、設定ファイル中の最初の 213 <code><VirtualHost></code> コンテナにそれを記述してください。</p> 214 215 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 216 <div class="section"> 217 <h2><a name="compat" id="compat">古いブラウザとの互換性</a></h2> 218 219 <p>以前述べたように、名前ベースのバーチャルホストが正しく動作する 220 ために必要な情報を送ってこないクライアントが依然として存在しています。 221 そのようなクライアントに対しては、該当する IP アドレスについて、 222 一番最初に設定されているバーチャルホスト 223 (<cite>プライマリ</cite>の名前ベースのバーチャルホスト) 224 からページが送り返されます。</p> 225 226 <div class="note"><h3>どのぐらい古いの ?</h3> 227 <p>「古い」と表現している場合、本当に古いことを意味して使っています。 228 不幸にして今現在でもこのような古いブラウザに遭遇することがあります。 229 現在のブラウザは全て、名前ベースのバーチャルホストに必要な 230 <code>Host</code> ヘッダを送ります。</p> 231 </div> 232 233 <p><a href="../mod/core.html#serverpath"><code>ServerPath</code></a> 234 ディレクティブで対処が可能です。ちょっと不格好ですけれども。</p> 235 236 <p>設定例</p> 237 238 <div class="example"><p><code> 239 NameVirtualHost 111.22.33.44<br /> 240 <br /> 241 <VirtualHost 111.22.33.44><br /> 242 <span class="indent"> 243 ServerName www.domain.tld<br /> 244 ServerPath /domain<br /> 245 DocumentRoot /web/domain<br /> 246 </span> 247 </VirtualHost><br /> 248 </code></p></div> 249 250 <p>この例にはどういう意味があるでしょうか? これは 251 "<code>/domain</code>" で始まる URI へのリクエストはすべて、 252 バーチャルホスト <code>www.domain.tld</code> で処理される、 253 という意味です。つまり、すべてのクライアントで 254 <code>http://www.domain.tld/domain/</code> でアクセスできるページが、 255 <code>Host:</code> ヘッダを送ってくるクライアントであれば 256 <code>http://www.domain.tld/</code> としてもアクセスできる、 257 という意味です。</p> 258 259 <p>これが動作するようにするには、 260 プライマリのバーチャルホストのページに 261 <code>http://www.domain.tld/domain/</code> へのリンクを設置します。 262 そして、バーチャルホストのページでは、純粋な相対リンク (<em>例:</em> 263 "<code>file.html</code>" や "<code>../icons/image.gif</code>")、 264 あるいは <code>/domain/</code> で始まるリンク (<em>例:</em> 265 "<code>http://www.domain.tld/domain/misc/file.html</code>" や 266 "<code>/domain/misc/file.html</code>") だけを設置します。</p> 267 268 <p>これには、幾分かの規律が必要となりますが、 269 このようなガイドラインを忠実に守ることにより、たいていの場合、 270 すべてのブラウザで ― 新しいブラウザでも古いものでも ― 271 作成したページが見えるということを保証します。</p> 272 273 </div></div> 274 <div class="bottomlang"> 275 <p><span>翻訳済み言語: </span><a href="../de/vhosts/name-based.html" hreflang="de" rel="alternate" title="Deutsch"> de </a> | 276 <a href="../en/vhosts/name-based.html" hreflang="en" rel="alternate" title="English"> en </a> | 277 <a href="../fr/vhosts/name-based.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | 278 <a href="../ja/vhosts/name-based.html" title="Japanese"> ja </a> | 279 <a href="../ko/vhosts/name-based.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | 280 <a href="../tr/vhosts/name-based.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> 281 </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">コメント</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div> 282 <script type="text/javascript"><!--//--><![CDATA[//><!-- 283 var comments_shortname = 'httpd'; 284 var comments_identifier = 'http://httpd.apache.org/docs/2.2/vhosts/name-based.html'; 285 (function(w, d) { 286 if (w.location.hostname.toLowerCase() == "httpd.apache.org") { 287 d.write('<div id="comments_thread"><\/div>'); 288 var s = d.createElement('script'); 289 s.type = 'text/javascript'; 290 s.async = true; 291 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; 292 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); 293 } 294 else { 295 d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); 296 } 297 })(window, document); 298 //--><!]]></script></div><div id="footer"> 299 <p class="apache">Copyright 2017 The Apache Software Foundation.<br />この文書は <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a> のライセンスで提供されています。.</p> 300 <p class="menu"><a href="../mod/">モジュール</a> | <a href="../mod/directives.html">ディレクティブ</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">用語</a> | <a href="../sitemap.html">サイトマップ</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- 301 if (typeof(prettyPrint) !== 'undefined') { 302 prettyPrint(); 303 } 304 //--><!]]></script> 305 </body></html>