diff options
Diffstat (limited to '')
-rw-r--r-- | docs/manual/vhosts/examples.html | 21 | ||||
-rw-r--r-- | docs/manual/vhosts/examples.html.en | 566 | ||||
-rw-r--r-- | docs/manual/vhosts/examples.html.fr.utf8 | 586 | ||||
-rw-r--r-- | docs/manual/vhosts/examples.html.ja.utf8 | 680 | ||||
-rw-r--r-- | docs/manual/vhosts/examples.html.ko.euc-kr | 657 | ||||
-rw-r--r-- | docs/manual/vhosts/examples.html.tr.utf8 | 562 |
6 files changed, 3072 insertions, 0 deletions
diff --git a/docs/manual/vhosts/examples.html b/docs/manual/vhosts/examples.html new file mode 100644 index 0000000..73b5188 --- /dev/null +++ b/docs/manual/vhosts/examples.html @@ -0,0 +1,21 @@ +# GENERATED FROM XML -- DO NOT EDIT + +URI: examples.html.en +Content-Language: en +Content-type: text/html; charset=UTF-8 + +URI: examples.html.fr.utf8 +Content-Language: fr +Content-type: text/html; charset=UTF-8 + +URI: examples.html.ja.utf8 +Content-Language: ja +Content-type: text/html; charset=UTF-8 + +URI: examples.html.ko.euc-kr +Content-Language: ko +Content-type: text/html; charset=EUC-KR + +URI: examples.html.tr.utf8 +Content-Language: tr +Content-type: text/html; charset=UTF-8 diff --git a/docs/manual/vhosts/examples.html.en b/docs/manual/vhosts/examples.html.en new file mode 100644 index 0000000..6c4f333 --- /dev/null +++ b/docs/manual/vhosts/examples.html.en @@ -0,0 +1,566 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head> +<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> +<!-- + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + This file is generated from xml source: DO NOT EDIT + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + --> +<title>VirtualHost Examples - Apache HTTP Server Version 2.4</title> +<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> +<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> +<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" /> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> +</script> + +<link href="../images/favicon.ico" rel="shortcut icon" /></head> +<body id="manual-page"><div id="page-header"> +<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<p class="apache">Apache HTTP Server Version 2.4</p> +<img alt="" src="../images/feather.png" /></div> +<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> +<div id="path"> +<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.4</a> > <a href="./">Virtual Hosts</a></div><div id="page-content"><div id="preamble"><h1>VirtualHost Examples</h1> +<div class="toplang"> +<p><span>Available Languages: </span><a href="../en/vhosts/examples.html" title="English"> en </a> | +<a href="../fr/vhosts/examples.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | +<a href="../ja/vhosts/examples.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | +<a href="../ko/vhosts/examples.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | +<a href="../tr/vhosts/examples.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> +</div> + + + <p>This document attempts to answer the commonly-asked questions about + setting up <a href="index.html">virtual hosts</a>. These scenarios are those involving multiple + web sites running on a single server, via <a href="name-based.html">name-based</a> or <a href="ip-based.html">IP-based</a> virtual hosts. + </p> + +</div> +<div id="quickview"><a href="https://www.apache.org/foundation/contributing.html" class="badge"><img src="https://www.apache.org/images/SupportApache-small.png" alt="Support Apache!" /></a><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#purename">Running several name-based web + sites on a single IP address.</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#twoips">Name-based hosts on more than one + IP address.</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#intraextra">Serving the same content on + different IP addresses (such as an internal and external + address).</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#port">Running different sites on different + ports.</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#ip">IP-based virtual hosting</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#ipport">Mixed port-based and ip-based virtual + hosts</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#mixed">Mixed name-based and IP-based + vhosts</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#proxy">Using <code>Virtual_host</code> and + mod_proxy together</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#default">Using <code>_default_</code> + vhosts</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#migrate">Migrating a name-based vhost to an + IP-based vhost</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#serverpath">Using the <code>ServerPath</code> + directive</a></li> +</ul><h3>See also</h3><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div> +<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="purename" id="purename">Running several name-based web + sites on a single IP address.</a></h2> + + <p>Your server has multiple hostnames that resolve to a single address, + and you want to respond differently for <code>www.example.com</code> + and <code>www.example.org</code>.</p> + + <div class="note"><h3>Note</h3><p>Creating virtual + host configurations on your Apache server does not magically + cause DNS entries to be created for those host names. You + <em>must</em> have the names in DNS, resolving to your IP + address, or nobody else will be able to see your web site. You + can put entries in your <code>hosts</code> file for local + testing, but that will work only from the machine with those + <code>hosts</code> entries.</p> + </div> + + <pre class="prettyprint lang-config"># Ensure that Apache listens on port 80 +Listen 80 +<VirtualHost *:80> + DocumentRoot "/www/example1" + ServerName www.example.com + + # Other directives here +</VirtualHost> + +<VirtualHost *:80> + DocumentRoot "/www/example2" + ServerName www.example.org + + # Other directives here +</VirtualHost></pre> + + + <p>The asterisks match all addresses, so the main server serves no + requests. Due to the fact that the virtual host with + <code>ServerName www.example.com</code> is first + in the configuration file, it has the highest priority and can be seen + as the <cite>default</cite> or <cite>primary</cite> server. That means + that if a request is received that does not match one of the specified + <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code> directives, it will be served by this first + <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code>.</p> + + <p>The above configuration is what you will want to use in almost + all name-based virtual hosting situations. The only thing that this + configuration will not work for, in fact, is when you are serving + different content based on differing IP addresses or ports.</p> + + <div class="note"> + <h3>Note</h3> + + <p>You may replace <code>*</code> with a specific IP address + on the system. Such virtual hosts will only be used for + HTTP requests received on connection to the specified IP + address.</p> + + <p>However, it is additionally useful to use <code>*</code> + on systems where the IP address is not predictable - for + example if you have a dynamic IP address with your ISP, and + you are using some variety of dynamic DNS solution. Since + <code>*</code> matches any IP address, this configuration + would work without changes whenever your IP address + changes.</p> + </div> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="twoips" id="twoips">Name-based hosts on more than one + IP address.</a></h2> + + <div class="note"> + <h3>Note</h3> + <p>Any of the techniques discussed here can be extended to any + number of IP addresses.</p> + </div> + + <p>The server has two IP addresses. On one (<code>172.20.30.40</code>), we + will serve the "main" server, <code>server.example.com</code> and on the + other (<code>172.20.30.50</code>), we will serve two or more virtual hosts.</p> + + <pre class="prettyprint lang-config">Listen 80 + +# This is the "main" server running on 172.20.30.40 +ServerName server.example.com +DocumentRoot "/www/mainserver" + +<VirtualHost 172.20.30.50> + DocumentRoot "/www/example1" + ServerName www.example.com + + # Other directives here ... +</VirtualHost> + +<VirtualHost 172.20.30.50> + DocumentRoot "/www/example2" + ServerName www.example.org + + # Other directives here ... +</VirtualHost></pre> + + + <p>Any request to an address other than <code>172.20.30.50</code> will be + served from the main server. A request to <code>172.20.30.50</code> with an + unknown hostname, or no <code>Host:</code> header, will be served from + <code>www.example.com</code>.</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="intraextra" id="intraextra">Serving the same content on + different IP addresses (such as an internal and external + address).</a></h2> + + <p>The server machine has two IP addresses (<code>192.168.1.1</code> + and <code>172.20.30.40</code>). The machine is sitting between an + internal (intranet) network and an external (internet) network. Outside + of the network, the name <code>server.example.com</code> resolves to + the external address (<code>172.20.30.40</code>), but inside the + network, that same name resolves to the internal address + (<code>192.168.1.1</code>).</p> + + <p>The server can be made to respond to internal and external requests + with the same content, with just one <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> section.</p> + + <pre class="prettyprint lang-config"><VirtualHost 192.168.1.1 172.20.30.40> + DocumentRoot "/www/server1" + ServerName server.example.com + ServerAlias server +</VirtualHost></pre> + + + <p>Now requests from both networks will be served from the same + <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code>.</p> + + <div class="note"> + <h3>Note:</h3><p>On the internal + network, one can just use the name <code>server</code> rather + than the fully qualified host name + <code>server.example.com</code>.</p> + + <p>Note also that, in the above example, you can replace the list + of IP addresses with <code>*</code>, which will cause the server to + respond the same on all addresses.</p> + </div> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="port" id="port">Running different sites on different + ports.</a></h2> + + <p>You have multiple domains going to the same IP and also want to + serve multiple ports. The example below illustrates that the name-matching + takes place after the best matching IP address and port combination + is determined.</p> + + <pre class="prettyprint lang-config">Listen 80 +Listen 8080 + +<VirtualHost 172.20.30.40:80> + ServerName www.example.com + DocumentRoot "/www/domain-80" +</VirtualHost> + +<VirtualHost 172.20.30.40:8080> + ServerName www.example.com + DocumentRoot "/www/domain-8080" +</VirtualHost> + +<VirtualHost 172.20.30.40:80> + ServerName www.example.org + DocumentRoot "/www/otherdomain-80" +</VirtualHost> + +<VirtualHost 172.20.30.40:8080> + ServerName www.example.org + DocumentRoot "/www/otherdomain-8080" +</VirtualHost></pre> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="ip" id="ip">IP-based virtual hosting</a></h2> + + <p>The server has two IP addresses (<code>172.20.30.40</code> and + <code>172.20.30.50</code>) which resolve to the names + <code>www.example.com</code> and <code>www.example.org</code> + respectively.</p> + + <pre class="prettyprint lang-config">Listen 80 + +<VirtualHost 172.20.30.40> + DocumentRoot "/www/example1" + ServerName www.example.com +</VirtualHost> + +<VirtualHost 172.20.30.50> + DocumentRoot "/www/example2" + ServerName www.example.org +</VirtualHost></pre> + + + <p>Requests for any address not specified in one of the + <code><VirtualHost></code> directives (such as + <code>localhost</code>, for example) will go to the main server, if + there is one.</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="ipport" id="ipport">Mixed port-based and ip-based virtual + hosts</a></h2> + + <p>The server machine has two IP addresses (<code>172.20.30.40</code> and + <code>172.20.30.50</code>) which resolve to the names + <code>www.example.com</code> and <code>www.example.org</code> + respectively. In each case, we want to run hosts on ports 80 and + 8080.</p> + + <pre class="prettyprint lang-config">Listen 172.20.30.40:80 +Listen 172.20.30.40:8080 +Listen 172.20.30.50:80 +Listen 172.20.30.50:8080 + +<VirtualHost 172.20.30.40:80> + DocumentRoot "/www/example1-80" + ServerName www.example.com +</VirtualHost> + +<VirtualHost 172.20.30.40:8080> + DocumentRoot "/www/example1-8080" + ServerName www.example.com +</VirtualHost> + +<VirtualHost 172.20.30.50:80> + DocumentRoot "/www/example2-80" + ServerName www.example.org +</VirtualHost> + +<VirtualHost 172.20.30.50:8080> + DocumentRoot "/www/example2-8080" + ServerName www.example.org +</VirtualHost></pre> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="mixed" id="mixed">Mixed name-based and IP-based + vhosts</a></h2> + + <p>Any address mentioned in the argument to a virtualhost that never + appears in another virtual host is a strictly IP-based virtual host.</p> + + <pre class="prettyprint lang-config">Listen 80 +<VirtualHost 172.20.30.40> + DocumentRoot "/www/example1" + ServerName www.example.com +</VirtualHost> + +<VirtualHost 172.20.30.40> + DocumentRoot "/www/example2" + ServerName www.example.org +</VirtualHost> + +<VirtualHost 172.20.30.40> + DocumentRoot "/www/example3" + ServerName www.example.net +</VirtualHost> + +# IP-based +<VirtualHost 172.20.30.50> + DocumentRoot "/www/example4" + ServerName www.example.edu +</VirtualHost> + +<VirtualHost 172.20.30.60> + DocumentRoot "/www/example5" + ServerName www.example.gov +</VirtualHost></pre> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="proxy" id="proxy">Using <code>Virtual_host</code> and + mod_proxy together</a></h2> + + <p>The following example allows a front-end machine to proxy a + virtual host through to a server running on another machine. In the + example, a virtual host of the same name is configured on a machine + at <code>192.168.111.2</code>. The <code class="directive"><a href="../mod/mod_proxy.html#proxypreservehost">ProxyPreserveHost + On</a></code> directive is used so that the desired hostname is + passed through, in case we are proxying multiple hostnames to a + single machine.</p> + + <pre class="prettyprint lang-config"><VirtualHost *:*> + ProxyPreserveHost On + ProxyPass "/" "http://192.168.111.2/" + ProxyPassReverse "/" "http://192.168.111.2/" + ServerName hostname.example.com +</VirtualHost></pre> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="default" id="default">Using <code>_default_</code> + vhosts</a></h2> + + <h3><a name="defaultallports" id="defaultallports"><code>_default_</code> vhosts + for all ports</a></h3> + + <p>Catching <em>every</em> request to any unspecified IP address and + port, <em>i.e.</em>, an address/port combination that is not used for + any other virtual host.</p> + + <pre class="prettyprint lang-config"><VirtualHost _default_:*> + DocumentRoot "/www/default" +</VirtualHost></pre> + + + <p>Using such a default vhost with a wildcard port effectively prevents + any request going to the main server.</p> + + <p>A default vhost never serves a request that was sent to an + address/port that is used for name-based vhosts. If the request + contained an unknown or no <code>Host:</code> header it is always + served from the primary name-based vhost (the vhost for that + address/port appearing first in the configuration file).</p> + + <p>You can use <code class="directive"><a href="../mod/mod_alias.html#aliasmatch">AliasMatch</a></code> or + <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> to rewrite any + request to a single information page (or script).</p> + + + <h3><a name="defaultdifferentports" id="defaultdifferentports"><code>_default_</code> vhosts + for different ports</a></h3> + + <p>Same as setup 1, but the server listens on several ports and we want + to use a second <code>_default_</code> vhost for port 80.</p> + + <pre class="prettyprint lang-config"><VirtualHost _default_:80> + DocumentRoot "/www/default80" + # ... +</VirtualHost> + +<VirtualHost _default_:*> + DocumentRoot "/www/default" + # ... +</VirtualHost></pre> + + + <p>The default vhost for port 80 (which <em>must</em> appear before any + default vhost with a wildcard port) catches all requests that were sent + to an unspecified IP address. The main server is never used to serve a + request.</p> + + + <h3><a name="defaultoneport" id="defaultoneport"><code>_default_</code> vhosts + for one port</a></h3> + + <p>We want to have a default vhost for port 80, but no other default + vhosts.</p> + + <pre class="prettyprint lang-config"><VirtualHost _default_:80> + DocumentRoot "/www/default" +... +</VirtualHost></pre> + + + <p>A request to an unspecified address on port 80 is served from the + default vhost. Any other request to an unspecified address and port is + served from the main server.</p> + + <p>Any use of <code>*</code> in a virtual host declaration will have + higher precedence than <code>_default_</code>.</p> + + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="migrate" id="migrate">Migrating a name-based vhost to an + IP-based vhost</a></h2> + + <p>The name-based vhost with the hostname + <code>www.example.org</code> (from our <a href="#name">name-based</a> example, setup 2) should get its own IP + address. To avoid problems with name servers or proxies who cached the + old IP address for the name-based vhost we want to provide both + variants during a migration phase.</p> + + <p> + The solution is easy, because we can simply add the new IP address + (<code>172.20.30.50</code>) to the <code>VirtualHost</code> + directive.</p> + + <pre class="prettyprint lang-config">Listen 80 +ServerName www.example.com +DocumentRoot "/www/example1" + +<VirtualHost 172.20.30.40 172.20.30.50> + DocumentRoot "/www/example2" + ServerName www.example.org + # ... +</VirtualHost> + +<VirtualHost 172.20.30.40> + DocumentRoot "/www/example3" + ServerName www.example.net + ServerAlias *.example.net + # ... +</VirtualHost></pre> + + + <p>The vhost can now be accessed through the new address (as an + IP-based vhost) and through the old address (as a name-based + vhost).</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="serverpath" id="serverpath">Using the <code>ServerPath</code> + directive</a></h2> + + <p>We have a server with two name-based vhosts. In order to match the + correct virtual host a client must send the correct <code>Host:</code> + header. Old HTTP/1.0 clients do not send such a header and Apache has + no clue what vhost the client tried to reach (and serves the request + from the primary vhost). To provide as much backward compatibility as + possible we create a primary vhost which returns a single page + containing links with an URL prefix to the name-based virtual + hosts.</p> + + <pre class="prettyprint lang-config"><VirtualHost 172.20.30.40> + # primary vhost + DocumentRoot "/www/subdomain" + RewriteEngine On + RewriteRule "." "/www/subdomain/index.html" + # ... +</VirtualHost> + +<VirtualHost 172.20.30.40> + DocumentRoot "/www/subdomain/sub1" + ServerName www.sub1.domain.tld + ServerPath "/sub1/" + RewriteEngine On + RewriteRule "^(/sub1/.*)" "/www/subdomain$1" + # ... +</VirtualHost> + +<VirtualHost 172.20.30.40> + DocumentRoot "/www/subdomain/sub2" + ServerName www.sub2.domain.tld + ServerPath "/sub2/" + RewriteEngine On + RewriteRule "^(/sub2/.*)" "/www/subdomain$1" + # ... +</VirtualHost></pre> + + + <p>Due to the <code class="directive"><a href="../mod/core.html#serverpath">ServerPath</a></code> + directive a request to the URL + <code>http://www.sub1.domain.tld/sub1/</code> is <em>always</em> served + from the sub1-vhost.<br /> A request to the URL + <code>http://www.sub1.domain.tld/</code> is only + served from the sub1-vhost if the client sent a correct + <code>Host:</code> header. If no <code>Host:</code> header is sent the + client gets the information page from the primary host.</p> + + <p>Please note that there is one oddity: A request to + <code>http://www.sub2.domain.tld/sub1/</code> is also served from the + sub1-vhost if the client sent no <code>Host:</code> header.</p> + + <p>The <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> directives + are used to make sure that a client which sent a correct + <code>Host:</code> header can use both URL variants, <em>i.e.</em>, + with or without URL prefix.</p> + + </div></div> +<div class="bottomlang"> +<p><span>Available Languages: </span><a href="../en/vhosts/examples.html" title="English"> en </a> | +<a href="../fr/vhosts/examples.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | +<a href="../ja/vhosts/examples.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | +<a href="../ko/vhosts/examples.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | +<a href="../tr/vhosts/examples.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> +</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">Comments</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 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 Libera.chat, or sent to our <a href="https://httpd.apache.org/lists.html">mailing lists</a>.</div> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/vhosts/examples.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> +<p class="apache">Copyright 2023 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- +if (typeof(prettyPrint) !== 'undefined') { + prettyPrint(); +} +//--><!]]></script> +</body></html>
\ No newline at end of file diff --git a/docs/manual/vhosts/examples.html.fr.utf8 b/docs/manual/vhosts/examples.html.fr.utf8 new file mode 100644 index 0000000..f8851a7 --- /dev/null +++ b/docs/manual/vhosts/examples.html.fr.utf8 @@ -0,0 +1,586 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr"><head> +<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> +<!-- + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + This file is generated from xml source: DO NOT EDIT + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + --> +<title>Exemples d'utilisations de VirtualHost - Serveur HTTP Apache Version 2.4</title> +<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> +<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> +<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" /> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> +</script> + +<link href="../images/favicon.ico" rel="shortcut icon" /></head> +<body id="manual-page"><div id="page-header"> +<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p> +<p class="apache">Serveur HTTP Apache Version 2.4</p> +<img alt="" src="../images/feather.png" /></div> +<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> +<div id="path"> +<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">Serveur HTTP</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.4</a> > <a href="./">Serveurs virtuels</a></div><div id="page-content"><div id="preamble"><h1>Exemples d'utilisations de VirtualHost</h1> +<div class="toplang"> +<p><span>Langues Disponibles: </span><a href="../en/vhosts/examples.html" hreflang="en" rel="alternate" title="English"> en </a> | +<a href="../fr/vhosts/examples.html" title="Français"> fr </a> | +<a href="../ja/vhosts/examples.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | +<a href="../ko/vhosts/examples.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | +<a href="../tr/vhosts/examples.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> +</div> + + + <p>Le but de ce document est d'essayer de répondre aux questions + les plus répandues sur la configuration des <a href="index.html">serveurs virtuels</a>. + Les scénarios présentés ici se rencontrent quand plusieurs + serveurs Webs doivent tourner sur une seule et même machine au + moyen de serveurs virtuels <a href="name-based.html">par nom</a> + ou <a href="ip-based.html">par IP</a>.</p> + +</div> +<div id="quickview"><a href="https://www.apache.org/foundation/contributing.html" class="badge"><img src="https://www.apache.org/images/SupportApache-small.png" alt="Support Apache!" /></a><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#purename">Fonctionnement de plusieurs serveurs + virtuels par nom sur une seule adresse IP.</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#twoips">Serveurs virtuels par nom sur plus + d'une seule adresse IP.</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#intraextra">Servir le même contenu sur des + adresses IP différentes (telle qu'une adresse interne et une + externe).</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#port">Servir différents sites sur différents + ports.</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#ip">Hébergement virtuel basé sur IP</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#ipport">Hébergements virtuels mixtes basés sur + les ports et sur les IP</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#mixed">Hébergements virtuels mixtes basé sur + les noms et sur IP</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#proxy">Utilisation simultanée de + <code>Virtual_host</code> et de mod_proxy</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#default">Utilisation de serveurs virtuels + <code>_default_</code></a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#migrate">Migration d'un serveur virtuel + par nom en un serveur virtuel par IP</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#serverpath">Utilisation de la directive + <code>ServerPath</code></a></li> +</ul><h3>Voir aussi</h3><ul class="seealso"><li><a href="#comments_section">Commentaires</a></li></ul></div> +<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="purename" id="purename">Fonctionnement de plusieurs serveurs + virtuels par nom sur une seule adresse IP.</a></h2> + + <p>Votre serveur possède plusieurs noms d'hôte qui correspondent à une seule + adresse IP, et vous souhaitez des réponses différentes si on demande + <code>www.example.com</code> ou <code>www.example.org</code>.</p> + + <div class="note"><h3>Note :</h3><p>La configuration de serveurs virtuels + sous Apache ne provoque pas leur apparition magique dans la + configuration du DNS. Il <em>faut</em> que leurs noms soient + définis dans le DNS, et qu'ils y soient résolus sur l'adresse IP + du serveur, faute de quoi personne ne pourra visiter votre site Web. + Il est possible d'ajouter des entrées dans le fichier + <code>hosts</code> pour tests locaux, mais qui ne fonctionneront + que sur la machine possédant ces entrées.</p> + </div> + + <pre class="prettyprint lang-config"># Apache doit écouter sur le port 80 +Listen 80 +<VirtualHost *:80> + DocumentRoot "/www/example1" + ServerName www.example.com + + # Autres directives ici +</VirtualHost> + +<VirtualHost *:80> + DocumentRoot "/www/example2" + ServerName www.example.org + + # Autres directives ici +</VirtualHost></pre> + + + + <p>Les astérisques correspondent à toutes les adresses, si bien que + le serveur principal ne répondra jamais à aucune requête. Comme le + serveur virtuel + <code>ServerName www.example.com</code> se trouve en premier dans le fichier + de configuration, il a la plus grande priorité et peut être vu + comme serveur <cite>par défaut</cite> ou <cite>primaire</cite> ; + ce qui signifie que toute requête reçue ne correspondant à aucune + des directives <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code> sera servie par ce premier + <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code>.</p> + + <p>La configuration ci-dessus correspond à ce que l'on souhaite pour + la plupart des serveurs virtuels à base de nom. Il faudra cependant + utiliser une configuration différente si vous souhaitez servir un + contenu différent en fonction de l'adresse IP ou du port.</p> + + <div class="note"> + <h3>Note :</h3> + + <p>Vous pouvez remplacer <code>*</code> + par une adresse IP du système. Le serveur virtuel concerné + ne sera alors sélectionné que pour les requêtes HTTP vers + cette adresse IP.</p> + + <p>En général, il est commode d'utiliser <code>*</code> sur + les systèmes dont l'adresse IP n'est pas constante - par + exemple, pour des serveurs dont l'adresse IP est attribuée + dynamiquement par le FAI, et où le DNS est géré au moyen + d'un DNS dynamique quelconque. Comme <code>*</code> signifie + <cite>n'importe quelle adresse</cite>, cette configuration + fonctionne sans devoir être modifiée quand l'adresse IP du + système est modifiée.</p> + </div> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="twoips" id="twoips">Serveurs virtuels par nom sur plus + d'une seule adresse IP.</a></h2> + + <div class="note"> + <h3>Note :</h3><p>Toutes les techniques présentées ici + peuvent être étendues à un plus grand nombre d'adresses IP.</p> + </div> + + <p>Le serveur a deux adresses IP. Sur l'une + (<code>172.20.30.40</code>), le serveur "principal" + <code>server.example.com</code> doit répondre, et sur l'autre + (<code>172.20.30.50</code>), deux serveurs virtuels (ou plus) + répondront.</p> + + <pre class="prettyprint lang-config">Listen 80 + +# Serveur "principal" sur 172.20.30.40 +ServerName server.example.com +DocumentRoot "/www/mainserver" + +<VirtualHost 172.20.30.50> + DocumentRoot "/www/example1" + ServerName www.example.com + + # D'autres directives ici ... +</VirtualHost> + +<VirtualHost 172.20.30.50> + DocumentRoot "/www/example2" + ServerName www.example.org + + # D'autres directives ici ... +</VirtualHost></pre> + + + <p>Toute requête arrivant sur une autre adresse que + <code>172.20.30.50</code> sera servie par le serveur principal. + Les requêtes vers <code>172.20.30.50</code> avec un nom de serveur + inconnu, ou sans en-tête <code>Host:</code>, seront servies par + <code>www.example.com</code>.</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="intraextra" id="intraextra">Servir le même contenu sur des + adresses IP différentes (telle qu'une adresse interne et une + externe).</a></h2> + + <p>La machine serveur dispose de deux adresses IP + (<code>192.168.1.1</code> et <code>172.20.30.40</code>). Cette + machine est placée à la fois sur le réseau interne (l'Intranet) + et le réseau externe (Internet). Sur Internet, le nom + <code>server.example.com</code> pointe vers l'adresse externe + (<code>172.20.30.40</code>), mais sur le réseau interne, ce même + nom pointe vers l'adresse interne (<code>192.168.1.1</code>).</p> + + <p>Le serveur peut être configuré pour répondre de la même manière + aux requêtes internes et externes, au moyen d'une seule section + <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code>.</p> + + <pre class="prettyprint lang-config"><VirtualHost 192.168.1.1 172.20.30.40> + DocumentRoot "/www/server1" + ServerName server.example.com + ServerAlias server +</VirtualHost></pre> + + + <p>Ainsi, les requêtes en provenance de chacun des deux réseaux + seront servies par le même <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code>.</p> + + <div class="note"> + <h3>Note :</h3><p>Sur le réseau interne, il est possible + d'utiliser le nom raccourci <code>server</code> au lieu du nom + complet <code>server.example.com</code>.</p> + + <p>Notez également que dans l'exemple précédent, vous pouvez + remplacer la liste des adresses IP par des <code>*</code> afin + que le serveur réponde de la même manière sur toutes ses + adresses.</p> + </div> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="port" id="port">Servir différents sites sur différents + ports.</a></h2> + + <p>Vous disposez de plusieurs domaines pointant sur la même adresse + IP et vous voulez également servir de multiples ports. L'exemple + suivant montre que la sélection en fonction du nom intervient après + la sélection de la meilleure correspondance du point de vue adresse + IP/port.</p> + + <pre class="prettyprint lang-config">Listen 80 +Listen 8080 + +<VirtualHost 172.20.30.40:80> + ServerName www.example.com + DocumentRoot "/www/domain-80" +</VirtualHost> + +<VirtualHost 172.20.30.40:8080> + ServerName www.example.com + DocumentRoot "/www/domain-8080" +</VirtualHost> + +<VirtualHost 172.20.30.40:80> + ServerName www.example.org + DocumentRoot "/www/otherdomain-80" +</VirtualHost> + +<VirtualHost 172.20.30.40:8080> + ServerName www.example.org + DocumentRoot "/www/otherdomain-8080" +</VirtualHost></pre> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="ip" id="ip">Hébergement virtuel basé sur IP</a></h2> + + <p>Le serveur dispose de deux adresses IP (<code>172.20.30.40</code> + et <code>172.20.30.50</code>) correspondant respectivement aux noms + <code>www.example.com</code> et <code>www.example.org</code>.</p> + + <pre class="prettyprint lang-config">Listen 80 + +<VirtualHost 172.20.30.40> + DocumentRoot "/www/example1" + ServerName www.example.com +</VirtualHost> + +<VirtualHost 172.20.30.50> + DocumentRoot "/www/example2" + ServerName www.example.org +</VirtualHost></pre> + + + <p>Les requêtes provenant d'adresses non spécifiées dans l'une des + directives <code><VirtualHost></code> (comme pour + <code>localhost</code> par exemple) seront dirigées vers le serveur + principal, s'il en existe un.</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="ipport" id="ipport">Hébergements virtuels mixtes basés sur + les ports et sur les IP</a></h2> + + <p>Le serveur dispose de deux adresses IP (<code>172.20.30.40</code> + et <code>172.20.30.50</code>) correspondant respectivement aux noms + <code>www.example.com</code> et <code>www.example.org</code>. + Pour chacun d'eux, nous voulons un hébergement sur les ports 80 + et 8080.</p> + + <pre class="prettyprint lang-config">Listen 172.20.30.40:80 +Listen 172.20.30.40:8080 +Listen 172.20.30.50:80 +Listen 172.20.30.50:8080 + +<VirtualHost 172.20.30.40:80> + DocumentRoot "/www/example1-80" + ServerName www.example.com +</VirtualHost> + +<VirtualHost 172.20.30.40:8080> + DocumentRoot "/www/example1-8080" + ServerName www.example.com +</VirtualHost> + +<VirtualHost 172.20.30.50:80> + DocumentRoot "/www/example2-80" + ServerName www.example.org +</VirtualHost> + +<VirtualHost 172.20.30.50:8080> + DocumentRoot "/www/example2-8080" + ServerName www.example.org +</VirtualHost></pre> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="mixed" id="mixed">Hébergements virtuels mixtes basé sur + les noms et sur IP</a></h2> + + <p>Toute adresse indiquée comme argument d'une section VirtualHost + et n'apparaissant dans aucun autre serveur virtuel, fait de cette + section un serveur virtuel sélectionnable uniquement en fonction de + son adresse IP.</p> + + <pre class="prettyprint lang-config">Listen 80 +<VirtualHost 172.20.30.40> + DocumentRoot "/www/example1" + ServerName www.example.com +</VirtualHost> + +<VirtualHost 172.20.30.40> + DocumentRoot "/www/example2" + ServerName www.example.org +</VirtualHost> + +<VirtualHost 172.20.30.40> + DocumentRoot "/www/example3" + ServerName www.example.net +</VirtualHost> + +# IP-based +<VirtualHost 172.20.30.50> + DocumentRoot "/www/example4" + ServerName www.example.edu +</VirtualHost> + +<VirtualHost 172.20.30.60> + DocumentRoot "/www/example5" + ServerName www.example.gov +</VirtualHost></pre> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="proxy" id="proxy">Utilisation simultanée de + <code>Virtual_host</code> et de mod_proxy</a></h2> + + <p>L'exemple suivant montre comment une machine peut mandater + un serveur virtuel fonctionnant sur le serveur d'une autre machine. + Dans cet exemple, un serveur virtuel de même nom est configuré sur + une machine à l'adresse <code>192.168.111.2</code>. La directive + <code class="directive"><a href="../mod/mod_proxy.html#proxypreservehost">ProxyPreserveHost On</a></code> est + employée pour permette au nom de domaine d'être préservé lors du + transfert, au cas où plusieurs noms de domaines cohabitent sur + une même machine.</p> + + <pre class="prettyprint lang-config"><VirtualHost *:*> + ProxyPreserveHost On + ProxyPass "/" "http://192.168.111.2/" + ProxyPassReverse "/" "http://192.168.111.2/" + ServerName hostname.example.com +</VirtualHost></pre> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="default" id="default">Utilisation de serveurs virtuels + <code>_default_</code></a></h2> + + <h3><a name="defaultallports" id="defaultallports">Serveurs virtuels + <code>_default_</code> pour tous les ports</a></h3> + + <p>Exemple de capture de <em>toutes</em> les requêtes émanant + d'adresses IP ou de ports non connus, <em>c'est-à-dire</em>, d'un + couple adresse/port non traité par aucun autre serveur virtuel.</p> + + <pre class="prettyprint lang-config"><VirtualHost _default_:*> + DocumentRoot "/www/default" +</VirtualHost></pre> + + + <p>L'utilisation d'un tel serveur virtuel avec un joker pour le + port empêche de manière efficace qu'une requête n'atteigne le + serveur principal.</p> + + <p>Un serveur virtuel par défaut ne servira jamais une requête + qui est envoyée vers un couple adresse/port utilisée par un + serveur virtuel par nom. Si la requête contient un en-tête + <code>Host:</code> inconnu, ou si celui-ci est absent, elle + sera toujours servie par le serveur virtuel primaire par nom + (celui correspondant à ce couple adresse/port trouvé en premier + dans le fichier de configuration).</p> + + <p>Vous pouvez utiliser une directive + <code class="directive"><a href="../mod/mod_alias.html#aliasmatch">AliasMatch</a></code> ou + <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> afin de + réécrire une requête pour une unique page d'information (ou pour + un script).</p> + + + <h3><a name="defaultdifferentports" id="defaultdifferentports">Serveurs virtuels + <code>_default_</code> pour des ports différents</a></h3> + + <p>La configuration est similaire à l'exemple précédent, mais + le serveur écoute sur plusieurs ports et un second serveur virtuel + <code>_default_</code> pour le port 80 est ajouté.</p> + + <pre class="prettyprint lang-config"><VirtualHost _default_:80> + DocumentRoot "/www/default80" + # ... +</VirtualHost> + +<VirtualHost _default_:*> + DocumentRoot "/www/default" + # ... +</VirtualHost></pre> + + + <p>Le serveur virtuel par défaut défini pour le port 80 (il doit + impérativement être placé avant un autre serveur virtuel par + défaut traitant tous les ports grâce au joker *) capture toutes + les requêtes envoyées sur une adresse IP non spécifiée. Le + serveur principal n'est jamais utilisé pour servir une requête.</p> + + + <h3><a name="defaultoneport" id="defaultoneport">Serveurs virtuels + <code>_default_</code> pour un seul port</a></h3> + + <p>Nous voulons créer un serveur virtuel par défaut seulement + pour le port 80.</p> + + <pre class="prettyprint lang-config"><VirtualHost _default_:80> + DocumentRoot "/www/default" +... +</VirtualHost></pre> + + + <p>Une requête vers une adresse non spécifiée sur le port 80 + sera servie par le serveur virtuel par défaut, et toute autre + requête vers une adresse et un port non spécifiés sera servie + par le serveur principal.</p> + + <p>L'utilisation du caractère générique <code>*</code> dans la + déclaration d'un serveur virtuel l'emporte sur + <code>_default_</code>.</p> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="migrate" id="migrate">Migration d'un serveur virtuel + par nom en un serveur virtuel par IP</a></h2> + + <p>Le serveur virtuel par nom avec le nom de domaine + <code>www.example.org</code> (de notre <a href="#name">exemple + par nom</a>) devrait obtenir sa propre adresse IP. Pendant la + phase de migration, il est possible d'éviter les problèmes avec + les noms de serveurs et autres serveurs mandataires qui mémorisent + les vielles adresses IP pour les serveurs virtuels par nom.<br /> + La solution est simple, car il suffit d'ajouter la nouvelle + adresse IP (<code>172.20.30.50</code>) dans la directive + <code>VirtualHost</code>.</p> + + <pre class="prettyprint lang-config">Listen 80 +ServerName www.example.com +DocumentRoot "/www/example1" + +<VirtualHost 172.20.30.40 172.20.30.50> + DocumentRoot "/www/example2" + ServerName www.example.org + # ... +</VirtualHost> + +<VirtualHost 172.20.30.40> + DocumentRoot "/www/example3" + ServerName www.example.net + ServerAlias *.example.net + # ... +</VirtualHost></pre> + + + <p>Le serveur virtuel peut maintenant être joint par la nouvelle + adresse (comme un serveur virtuel par IP) et par l'ancienne + adresse (comme un serveur virtuel par nom).</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="serverpath" id="serverpath">Utilisation de la directive + <code>ServerPath</code></a></h2> + + <p>Dans le cas où vous disposez de deux serveurs virtuels par nom, + le client doit transmettre un en-tête <code>Host:</code> correct + pour déterminer le serveur concerné. Les vieux clients HTTP/1.0 + n'envoient pas un tel en-tête et Apache n'a aucun indice pour + connaître le serveur virtuel devant être joint (il sert la + requête à partir d'un serveur virtuel primaire). Dans un soucis + de préserver la compatibilité descendante, il suffit de créer + un serveur virtuel primaire chargé de retourner une page contenant + des liens dont les URLs auront un préfixe identifiant les serveurs + virtuels par nom.</p> + + <pre class="prettyprint lang-config"><VirtualHost 172.20.30.40> + # serveur virtuel primaire + DocumentRoot "/www/subdomain" + RewriteEngine On + RewriteRule "." "/www/subdomain/index.html" + # ... +</VirtualHost> + +<VirtualHost 172.20.30.40> + DocumentRoot "/www/subdomain/sub1" + ServerName www.sub1.domain.tld + ServerPath "/sub1/" + RewriteEngine On + RewriteRule "^(/sub1/.*)" "/www/subdomain$1 + # ... +</VirtualHost> + +<VirtualHost 172.20.30.40> + DocumentRoot "/www/subdomain/sub2" + ServerName www.sub2.domain.tld + ServerPath "/sub2/" + RewriteEngine On + RewriteRule "^(/sub2/.*)" "/www/subdomain$1" + # ... +</VirtualHost></pre> + + + <p>À cause de la directive + <code class="directive"><a href="../mod/core.html#serverpath">ServerPath</a></code>, une requête sur + une URL <code>http://www.sub1.domain.tld/sub1/</code> est + <em>toujours</em> servie par le serveur sub1-vhost.<br /> + Une requête sur une URL <code>http://www.sub1.domain.tld/</code> n'est + servie par le serveur sub1-vhost que si le client envoie un en-tête + <code>Host:</code> correct. Si aucun en-tête <code>Host:</code> + n'est transmis, le serveur primaire sera utilisé.</p> + <p>Notez qu'il y a une singularité : une requête sur + <code>http://www.sub2.domain.tld/sub1/</code> est également servie + par le serveur sub1-vhost si le client n'envoie pas d'en-tête + <code>Host:</code>.</p> + <p>Les directives <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> + sont employées pour s'assurer que le client qui envoie un en-tête + <code>Host:</code> correct puisse utiliser d'autres variantes d'URLs, + <em>c'est-à-dire</em> avec ou sans préfixe d'URL.</p> + + </div></div> +<div class="bottomlang"> +<p><span>Langues Disponibles: </span><a href="../en/vhosts/examples.html" hreflang="en" rel="alternate" title="English"> en </a> | +<a href="../fr/vhosts/examples.html" title="Français"> fr </a> | +<a href="../ja/vhosts/examples.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | +<a href="../ko/vhosts/examples.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | +<a href="../tr/vhosts/examples.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> +</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">Commentaires</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 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 Libera.chat, or sent to our <a href="https://httpd.apache.org/lists.html">mailing lists</a>.</div> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/vhosts/examples.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> +<p class="apache">Copyright 2023 The Apache Software Foundation.<br />Autorisé sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- +if (typeof(prettyPrint) !== 'undefined') { + prettyPrint(); +} +//--><!]]></script> +</body></html>
\ No newline at end of file diff --git a/docs/manual/vhosts/examples.html.ja.utf8 b/docs/manual/vhosts/examples.html.ja.utf8 new file mode 100644 index 0000000..7c31f0e --- /dev/null +++ b/docs/manual/vhosts/examples.html.ja.utf8 @@ -0,0 +1,680 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"><head> +<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> +<!-- + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + This file is generated from xml source: DO NOT EDIT + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + --> +<title>バーチャルホストの例 - Apache HTTP サーバ バージョン 2.4</title> +<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> +<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> +<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" /> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> +</script> + +<link href="../images/favicon.ico" rel="shortcut icon" /></head> +<body id="manual-page"><div id="page-header"> +<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> +<p class="apache">Apache HTTP サーバ バージョン 2.4</p> +<img alt="" src="../images/feather.png" /></div> +<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> +<div id="path"> +<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.4</a> > <a href="./">バーチャルホスト</a></div><div id="page-content"><div id="preamble"><h1>バーチャルホストの例</h1> +<div class="toplang"> +<p><span>翻訳済み言語: </span><a href="../en/vhosts/examples.html" hreflang="en" rel="alternate" title="English"> en </a> | +<a href="../fr/vhosts/examples.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | +<a href="../ja/vhosts/examples.html" title="Japanese"> ja </a> | +<a href="../ko/vhosts/examples.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | +<a href="../tr/vhosts/examples.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> +</div> +<div class="outofdate">この日本語訳はすでに古くなっている + 可能性があります。 + 最近更新された内容を見るには英語版をご覧下さい。 + </div> + + + <p>この文書は、バーチャルホストの設定の際に + よくある質問に答えるものです。想定している対象は <a href="name-based.html">名前ベース</a> や <a href="ip-based.html">IP ベース</a> のバーチャルホストを使って + 一つのサーバで複数のウェブサイトを運用している状況です。 + </p> + +</div> +<div id="quickview"><a href="https://www.apache.org/foundation/contributing.html" class="badge"><img src="https://www.apache.org/images/SupportApache-small.png" alt="Support Apache!" /></a><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#purename">一つの IP アドレスでいくつかの名前ベースの + ウェブサイトを実行する</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#twoips">複数の IP アドレスのあるホストで名前ベースの + ホスティングを行なう</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#intraextra">違う IP アドレス (例えば、内部と外部アドレス) + で同じコンテンツを送る</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#port">違うポートで違うサイトを運営する</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#ip">IP ベースのバーチャルホスティング</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#ipport">ポートベースと IP ベースの混ざった + バーチャルホスト</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#mixed">名前ベースと IP ベースを混ぜた + バーチャルホスト</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#proxy"><code>Virtual_host</code> と + mod_proxy を併用する</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#default"><code>_default_</code> のバーチャルホストを + 使う</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#migrate">名前ベースのバーチャルホストから IP ベースの + バーチャルホストに移行する</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#serverpath"><code>ServerPath</code> ディレクティブを + 使う</a></li> +</ul><h3>参照</h3><ul class="seealso"><li><a href="#comments_section">コメント</a></li></ul></div> +<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="purename" id="purename">一つの IP アドレスでいくつかの名前ベースの + ウェブサイトを実行する</a></h2> + + <p>サーバは IP アドレスを一つ割り当てられていて、DNS でマシンに + 複数の名前 (CNAME) が指定されています。このマシンで + <code>www.example.com</code> と <code>www.example.org</code> + のためのウェブサーバを実行させたいとします。</p> + + <div class="note"><h3>注</h3><p> + Apache サーバの設定でバーチャルホストの設定をしただけで、 + 知らない間にそのホスト名に対応する DNS のエントリが + 作成されたりはしません。そのサーバの IP アドレスに解決される + ように DNS に名前を登録しなければ<em>なりません</em>。 + そうでないと誰もあなたのウェブサイトを見ることはできません。 + ローカルでのテストのために <code>hosts</code> ファイルに + エントリを追加することもできますが、この場合はその + hosts エントリのあるマシンからしか動作しません。</p> + </div> + + <div class="example"><h3>サーバ設定</h3><p><code> + + + # Ensure that Apache listens on port 80<br /> + Listen 80<br /> + <br /> + # Listen for virtual host requests on all IP addresses<br /> + NameVirtualHost *:80<br /> + <br /> + <VirtualHost *:80><br /> + <span class="indent"> + DocumentRoot /www/example1<br /> + ServerName www.example.com<br /> + <br /> + # Other directives here<br /> + <br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost *:80><br /> + <span class="indent"> + DocumentRoot /www/example2<br /> + ServerName www.example.org<br /> + <br /> + # Other directives here<br /> + <br /> + </span> + </VirtualHost> + </code></p></div> + + <p>アスタリスクはすべてのアドレスにマッチしますので、主サーバは + リクエストを扱いません。<code>www.example.com</code> は + 最初にあるため、優先順位は一番高くなり、<cite>default</cite> もしくは + <cite>primary</cite> のサーバと考えることができます。つまり、リクエストが + どの <code>ServerName</code> ディレクティブにもマッチしない場合、 + 一番最初の <code>VirtualHost</code> により扱われます。</p> + + <div class="note"><h3>注</h3> + + <p><code>*</code> をシステムの実際の IP アドレスに置き換える + こともできます。その場合は <code>VirtualHost</code> の引数は + <code>NameVirtualHost</code> の引数と同じに<em>しなければなりません + </em>:</p> + + <div class="example"><p><code> + NameVirtualHost 172.20.30.40<br /> + <br /> + <VirtualHost 172.20.30.40><br /> + # etc ... + </code></p></div> + + <p>しかし、IP アドレスが予測不可能なシステム + ――例えばプロバイダから動的に IP アドレスを取得して何らかの + ダイナミック DNS を使っている場合など――においては、<code>*</code> + 指定はさらに便利です。<code>*</code> はすべての IP アドレスに + マッチしますので、この設定にしておけば IP アドレスが変更されても + 設定変更せずに動作します。</p> + </div> + + <p>名前ベースのバーチャルホスティングではほぼすべての状況で、 + 上記の設定で希望の設定になっていることでしょう。 + 実際この設定が動作しないのは、IP アドレスやポートの違いによって + 違うコンテンツを送るときだけです。</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="twoips" id="twoips">複数の IP アドレスのあるホストで名前ベースの + ホスティングを行なう</a></h2> + + <div class="note"> + <h3>注</h3><p>ここで説明されている方法は IP アドレスが + 何個あっても同様にできます。</p> + </div> + + <p>サーバには二つ IP アドレスがついています。一つ目 + (<code>172.20.30.40</code>) では主サーバ + <code>server.domain.com</code> を扱い、もう一方 + (<code>172.20.30.50</code>) では二つかそれ以上の数の + バーチャルホストを扱います。</p> + + <div class="example"><h3>サーバの設定</h3><p><code> + + + Listen 80<br /> + <br /> + # This is the "main" server running on 172.20.30.40<br /> + ServerName server.domain.com<br /> + DocumentRoot /www/mainserver<br /> + <br /> + # This is the other address<br /> + NameVirtualHost 172.20.30.50<br /> + <br /> + <VirtualHost 172.20.30.50><br /> + <span class="indent"> + DocumentRoot /www/example1<br /> + ServerName www.example.com<br /> + <br /> + # Other directives here ...<br /> + <br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.50><br /> + <span class="indent"> + DocumentRoot /www/example2<br /> + ServerName www.example.org<br /> + <br /> + # Other directives here ...<br /> + <br /> + </span> + </VirtualHost> + </code></p></div> + + <p><code>172.20.30.50</code> 以外のアドレスへのリクエストは主サーバ + が扱います。<code>172.20.30.50</code> への、未知のホスト名または + <code>Host:</code> ヘッダなしのリクエストは <code>www.example.com</code> + が扱います。</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="intraextra" id="intraextra">違う IP アドレス (例えば、内部と外部アドレス) + で同じコンテンツを送る</a></h2> + + <p>サーバマシンは IP アドレスを二つ (<code>192.168.1.1</code> + と <code>172.20.30.40</code>) 持っています。このマシンは内部 + (イントラネット) と 外部 (インターネット) のネットワークの間に + あります。<code>server.example.com</code> はネットワークの外からは + 外部アドレス (<code>172.20.30.40</code>) として解決されますが、 + ネットワークの中からは内部アドレス (<code>192.168.1.1</code>) + として解決されます。</p> + + <p><code>VirtualHost</code> 一つだけでサーバが内部のリクエストと + 外部のリクエストの両方に同じコンテンツで応答するようにできます。</p> + + <div class="example"><h3>サーバの設定</h3><p><code> + + + NameVirtualHost 192.168.1.1<br /> + NameVirtualHost 172.20.30.40<br /> + <br /> + <VirtualHost 192.168.1.1 172.20.30.40><br /> + <span class="indent"> + DocumentRoot /www/server1<br /> + ServerName server.example.com<br /> + ServerAlias server<br /> + </span> + </VirtualHost> + </code></p></div> + + <p>これでどちらのネットワークからのリクエストも同じ <code>VirtualHost</code> + で扱われるようになります。</p> + + <div class="note"><h3>注:</h3><p>内部ネットワークでは完全なホスト名の + <code>server.example.com</code> の代わりに、単に <code>server</code> + を使うことができます。</p> + + <p>上の例では、IP アドレスのリストを、すべてのアドレスに + 同じコンテンツで応答する <code>*</code> に置き換えられます。</p> + </div> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="port" id="port">違うポートで違うサイトを運営する</a></h2> + + <p>同じ IP に複数のドメインがあり、さらに複数のポートを使って + リクエストを扱いたいときがあります。"NameVirtualHost" タグの中で + ポートを定義することで、これを動作させられます。 + NameVirtualHost name:port 無しや Listen ディレクティブで + <VirtualHost name:port> を使おうとしても、その設定は動作しません。</p> + + <div class="example"><h3>サーバの設定</h3><p><code> + + + Listen 80<br /> + Listen 8080<br /> + <br /> + NameVirtualHost 172.20.30.40:80<br /> + NameVirtualHost 172.20.30.40:8080<br /> + <br /> + <VirtualHost 172.20.30.40:80><br /> + <span class="indent"> + ServerName www.example.com<br /> + DocumentRoot /www/domain-80<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40:8080><br /> + <span class="indent"> + ServerName www.example.com<br /> + DocumentRoot /www/domain-8080<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40:80><br /> + <span class="indent"> + ServerName www.example.org<br /> + DocumentRoot /www/otherdomain-80<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40:8080><br /> + <span class="indent"> + ServerName www.example.org<br /> + DocumentRoot /www/otherdomain-8080<br /> + </span> + </VirtualHost> + </code></p></div> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="ip" id="ip">IP ベースのバーチャルホスティング</a></h2> + + <p>サーバは <code>www.example.com</code> と <code>www.example.org</code> + にそれぞれ解決される、二つの IP アドレス (<code>172.20.30.40</code> と + <code>172.20.30.50</code>) があります。</p> + + <div class="example"><h3>サーバの設定</h3><p><code> + + + Listen 80<br /> + <br /> + <VirtualHost 172.20.30.40><br /> + <span class="indent"> + DocumentRoot /www/example1<br /> + ServerName www.example.com<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.50><br /> + <span class="indent"> + DocumentRoot /www/example2<br /> + ServerName www.example.org<br /> + </span> + </VirtualHost> + </code></p></div> + + <p><code><VirtualHost></code> ディレクティブのどれでも + 指定されていないアドレス (例えば <code>localhost</code>) は、 + 主サーバがあればそこに行きます。</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="ipport" id="ipport">ポートベースと IP ベースの混ざった + バーチャルホスト</a></h2> + + <p>サーバマシンはそれぞれ <code>www.example.com</code> と + <code>www.example.org</code> にそれぞれ解決される、IP アドレスを二つ + (<code>172.20.30.40</code> と <code>172.20.30.50</code>) 持っています。 + どちらもポート 80 と 8080 でホストを走らせます。</p> + + <div class="example"><h3>サーバの設定</h3><p><code> + + + Listen 172.20.30.40:80<br /> + Listen 172.20.30.40:8080<br /> + Listen 172.20.30.50:80<br /> + Listen 172.20.30.50:8080<br /> + <br /> + <VirtualHost 172.20.30.40:80><br /> + <span class="indent"> + DocumentRoot /www/example1-80<br /> + ServerName www.example.com<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40:8080><br /> + <span class="indent"> + DocumentRoot /www/example1-8080<br /> + ServerName www.example.com<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.50:80><br /> + <span class="indent"> + DocumentRoot /www/example2-80<br /> + ServerName www.example.org<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.50:8080><br /> + <span class="indent"> + DocumentRoot /www/example2-8080<br /> + ServerName www.example.org<br /> + </span> + </VirtualHost> + </code></p></div> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="mixed" id="mixed">名前ベースと IP ベースを混ぜた + バーチャルホスト</a></h2> + + <p>いくつかのマシンでは名前ベースの、その他では IP ベースのバーチャル + ホストをします。</p> + + <div class="example"><h3>サーバの設定</h3><p><code> + + + Listen 80<br /> + <br /> + NameVirtualHost 172.20.30.40<br /> + <br /> + <VirtualHost 172.20.30.40><br /> + <span class="indent"> + DocumentRoot /www/example1<br /> + ServerName www.example.com<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40><br /> + <span class="indent"> + DocumentRoot /www/example2<br /> + ServerName www.example.org<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40><br /> + <span class="indent"> + DocumentRoot /www/example3<br /> + ServerName www.example3.net<br /> + </span> + </VirtualHost><br /> + <br /> + # IP-based<br /> + <VirtualHost 172.20.30.50><br /> + <span class="indent"> + DocumentRoot /www/example4<br /> + ServerName www.example4.edu<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.60><br /> + <span class="indent"> + DocumentRoot /www/example5<br /> + ServerName www.example5.gov<br /> + </span> + </VirtualHost> + </code></p></div> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="proxy" id="proxy"><code>Virtual_host</code> と + mod_proxy を併用する</a></h2> + + <p>次の例は、フロント側のバーチャルホストで他のマシンへプロクシします。 + 例では <code>192.168.111.2</code> のマシンではバーチャルホスト名は + 同じ名前で設定されています。複数のホスト名を一台のマシンにプロクシする + 場合は、<code class="directive"><a href="../mod/mod_proxy.html#proxypreservehost on">ProxyPreserveHost On</a></code> + ディレクティブを使って、希望のホスト名を渡せるようになります。 + </p> + + <div class="example"><p><code> + <VirtualHost *:*><br /> + ProxyPreserveHost On<br /> + ProxyPass / http://192.168.111.2/<br /> + ProxyPassReverse / http://192.168.111.2/<br /> + ServerName hostname.example.com<br /> + </VirtualHost> + </code></p></div> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="default" id="default"><code>_default_</code> のバーチャルホストを + 使う</a></h2> + + <h3><a name="defaultallports" id="defaultallports">すべてのポートに対する + <code>_default_</code> バーチャルホスト</a></h3> + + <p>未指定の IP アドレスとポート、<em>つまり</em>他のバーチャルホストに + 使われていないアドレスとポートの組み合わせ、への<em>すべての</em>リクエストを + 受け取ります。</p> + + <div class="example"><h3>サーバの設定</h3><p><code> + + + <VirtualHost _default_:*><br /> + <span class="indent"> + DocumentRoot /www/default<br /> + </span> + </VirtualHost> + </code></p></div> + + <p>このようにワイルドカードのポートでデフォルトのバーチャルホストを + 指定すると、主サーバにリクエストが行くのを防げます。</p> + + <p>デフォルトのバーチャルホストは名前ベースのバーチャルホストに + 使われているアドレスとポートの組に送られたリクエストを扱うことは + ありません。リクエストが不明な <code>Host:</code> ヘッダやその + ヘッダがなかったりする場合は基本名前ベースバーチャルホスト (その + アドレスとポートで設定ファイル中で最初のバーチャルホスト) により + 扱われます。</p> + + <p>どんなリクエストでも <code class="directive"><a href="../mod/mod_alias.html#aliasmatch">AliasMatch</a></code> + や <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> を使って + 単一の情報ページ (やスクリプト) に書き換えることができます。</p> + + + <h3><a name="defaultdifferentports" id="defaultdifferentports">違うポートのための + <code>_default_</code> バーチャルホスト</a></h3> + + <p>一つめの設定とほぼ同じですが、サーバは複数のポートを listen しており、 + 80 番ポートに対して二つめの <code>_default_</code> バーチャルホストを + 設定したい場合です。</p> + + <div class="example"><h3>サーバの設定</h3><p><code> + + + <VirtualHost _default_:80><br /> + <span class="indent"> + DocumentRoot /www/default80<br /> + # ...<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost _default_:*><br /> + <span class="indent"> + DocumentRoot /www/default<br /> + # ...<br /> + </span> + </VirtualHost> + </code></p></div> + + <p>80 番ポートのデフォルトバーチャルホスト (ワイルドカードポートの + デフォルトバーチャルホストよりも前に書かれていなければ<em>なりません</em>) は + 未指定の IP アドレスに送られたすべてのリクエストを扱います。 + 主サーバはリクエストを扱いません。</p> + + + <h3><a name="defaultoneport" id="defaultoneport">一つのポートに対してだけの + <code>_default_</code> バーチャルホスト</a></h3> + + <p>80 番ポートにはデフォルトのバーチャルホストが必要で、他の + バーチャルホストはデフォルトが必要ない場合です。</p> + + <div class="example"><h3>サーバの設定</h3><p><code> + + + <VirtualHost _default_:80><br /> + DocumentRoot /www/default<br /> + ...<br /> + </VirtualHost> + </code></p></div> + + <p>80 番ポートへのアドレス未指定のリクエストはデフォルトのバーチャル + ホストから送られます。他の未指定のアドレスとポートへのリクエストは + 主サーバから送られます。</p> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="migrate" id="migrate">名前ベースのバーチャルホストから IP ベースの + バーチャルホストに移行する</a></h2> + + <p>ホスト名が名前 <code>www.example.org</code> のバーチャルホスト + (<a href="#name">名前ベース</a>の例の 2 番目の設定) が専用の IP アドレスを + 得たとします。名前ベースのバーチャルホストの古い IP アドレスを + キャッシュしているネームサーバやプロキシのために移行期間中は両方の + バーチャルホストを提供したいとします。</p> + + <p>答は簡単です。単に新しい IP アドレス (<code>172.20.30.50</code>) + を <code>VirtualHost</code> ディレクティブに追加することで + できます。</p> + + <div class="example"><h3>サーバ設定</h3><p><code> + + + Listen 80<br /> + ServerName www.example.com<br /> + DocumentRoot /www/example1<br /> + <br /> + NameVirtualHost 172.20.30.40<br /> + <br /> + <VirtualHost 172.20.30.40 172.20.30.50><br /> + <span class="indent"> + DocumentRoot /www/example2<br /> + ServerName www.example.org<br /> + # ...<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40><br /> + <span class="indent"> + DocumentRoot /www/example3<br /> + ServerName www.example.net<br /> + ServerAlias *.example.net<br /> + # ...<br /> + </span> + </VirtualHost> + </code></p></div> + + <p>このバーチャルホストは新しいアドレス (IP ベースのバーチャルホストとして) + と古いアドレス(名前ベースのバーチャルホストとして) の両方から + アクセスできます。</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="serverpath" id="serverpath"><code>ServerPath</code> ディレクティブを + 使う</a></h2> + + <p>名前ベースのバーチャルホストが二つあるサーバがあるとします。 + 正しいバーチャルホストを得るためにはクライアントは正しい + <code>Host:</code> ヘッダを送らなければなりません。 + 古い HTTP/1.0 はそのようなヘッダを送らないので、Apache はクライアントが + どのバーチャルホストを意図したのかさっぱりわかりません + (なので、主バーチャルホストでリクエストを扱います)。 + 可能な限りの下位互換性を得るため、名前ベースのバーチャルホストの + URL 接頭辞へのリンクの書かれたページを返す、 + 主バーチャルホストが作成されます。</p> + + <div class="example"><h3>サーバの設定</h3><p><code> + + + NameVirtualHost 172.20.30.40<br /> + <br /> + <VirtualHost 172.20.30.40><br /> + <span class="indent"> + # primary vhost<br /> + DocumentRoot /www/subdomain<br /> + RewriteEngine On<br /> + RewriteRule ^/.* /www/subdomain/index.html<br /> + # ...<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40><br /> + DocumentRoot /www/subdomain/sub1<br /> + <span class="indent"> + ServerName www.sub1.domain.tld<br /> + ServerPath /sub1/<br /> + RewriteEngine On<br /> + RewriteRule ^(/sub1/.*) /www/subdomain$1<br /> + # ...<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40><br /> + <span class="indent"> + DocumentRoot /www/subdomain/sub2<br /> + ServerName www.sub2.domain.tld<br /> + ServerPath /sub2/<br /> + RewriteEngine On<br /> + RewriteRule ^(/sub2/.*) /www/subdomain$1<br /> + # ...<br /> + </span> + </VirtualHost> + </code></p></div> + + <p><code class="directive"><a href="../mod/core.html#serverpath">ServerPath</a></code> ディレクティブの設定に + より、URL <code>http://www.sub1.domain.tld/sub1/</code> は + <em>常に</em> sub1-vhost により扱われます。URL + <code>http://www.sub1.domain.tld/</code> へのリクエストは + クライアントが正しい <code>Host:</code> ヘッダを送ったときにのみ + sub1-vhost から送られます。<code>Host:</code> ヘッダがなければ + クライアントは主ホストの情報ページを得ます。</p> + + <p>一つ奇妙な動作をする点があることは覚えておいてください。 + <code>http://www.sub2.domain.tld/sub1/</code> へのリクエストも + <code>Host:</code> ヘッダがなければ sub1-vhost により扱われます。</p> + + <p>正しい <code>Host:</code> ヘッダを送ったクライアントはどちらの + URL、<em>つまり</em>接頭辞がある方も無い方も使えるように + <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> ディレクティブが + 使われています。</p> + </div></div> +<div class="bottomlang"> +<p><span>翻訳済み言語: </span><a href="../en/vhosts/examples.html" hreflang="en" rel="alternate" title="English"> en </a> | +<a href="../fr/vhosts/examples.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | +<a href="../ja/vhosts/examples.html" title="Japanese"> ja </a> | +<a href="../ko/vhosts/examples.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | +<a href="../tr/vhosts/examples.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> +</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 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 Libera.chat, or sent to our <a href="https://httpd.apache.org/lists.html">mailing lists</a>.</div> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/vhosts/examples.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> +<p class="apache">Copyright 2023 The Apache Software Foundation.<br />この文書は <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a> のライセンスで提供されています。.</p> +<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[//><!-- +if (typeof(prettyPrint) !== 'undefined') { + prettyPrint(); +} +//--><!]]></script> +</body></html>
\ No newline at end of file diff --git a/docs/manual/vhosts/examples.html.ko.euc-kr b/docs/manual/vhosts/examples.html.ko.euc-kr new file mode 100644 index 0000000..ebe9e0c --- /dev/null +++ b/docs/manual/vhosts/examples.html.ko.euc-kr @@ -0,0 +1,657 @@ +<?xml version="1.0" encoding="EUC-KR"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="ko" xml:lang="ko"><head> +<meta content="text/html; charset=EUC-KR" http-equiv="Content-Type" /> +<!-- + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + This file is generated from xml source: DO NOT EDIT + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + --> +<title>ȣƮ - Apache HTTP Server Version 2.4</title> +<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> +<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> +<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" /> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> +</script> + +<link href="../images/favicon.ico" rel="shortcut icon" /></head> +<body id="manual-page"><div id="page-header"> +<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> +<p class="apache">Apache HTTP Server Version 2.4</p> +<img alt="" src="../images/feather.png" /></div> +<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> +<div id="path"> +<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.4</a> > <a href="./">ȣƮ</a></div><div id="page-content"><div id="preamble"><h1>ȣƮ </h1> +<div class="toplang"> +<p><span> : </span><a href="../en/vhosts/examples.html" hreflang="en" rel="alternate" title="English"> en </a> | +<a href="../fr/vhosts/examples.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | +<a href="../ja/vhosts/examples.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | +<a href="../ko/vhosts/examples.html" title="Korean"> ko </a> | +<a href="../tr/vhosts/examples.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> +</div> +<div class="outofdate"> ֽ ƴմϴ. + ֱٿ ϼ.</div> + + + <p> ǵǴ ȣƮ + Ϸ . Ȳ <a href="name-based.html"≯</a>̳ <a href="ip-based.html">IP</a> ȣƮ + Ʈ Ϸ ̴. Ͻ ڿ + Ͽ Ʈ ϴ 츦 ٷ + ̴.</p> + +</div> +<div id="quickview"><a href="https://www.apache.org/foundation/contributing.html" class="badge"><img src="https://www.apache.org/images/SupportApache-small.png" alt="Support Apache!" /></a><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#purename">IP ּ Ѱ ̸ + Ʈ ϱ.</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#twoips"> IP ּҿ ̸ + ȣƮ.</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#intraextra">(ο ܺ ּҿ ) + ٸ IP ּҷ ϱ.</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#port"> Ʈ ٸ Ʈ + ϱ.</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#ip">IP ȣƮ</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#ipport">Ʈݰ ip ȥյ + ȣƮ</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#mixed"≯ݰ IP ȥյ + ȣƮ</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#default"><code>_default_</code> ȣƮ + ϱ</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#migrate"≯ ȣƮ IP + ȣƮ ű</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#serverpath"><code>ServerPath</code> + þ ϱ</a></li> +</ul><h3></h3><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div> +<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="purename" id="purename">IP ּ Ѱ ̸ + Ʈ ϱ.</a></h2> + + <p> IP ּҰ Ѱ ְ, DNS ּ(CNAMES) + ǻ Ų. ǻͿ <code>www.example.com</code> + <code>www.example.org</code> ϰ ʹ.</p> + + <div class="note"><h3>Note</h3><p>ġ ȣƮ + Ѵٰ ȣƮ DNS ڵ̷ + ʴ´. <em>ݵ</em> DNS IP ּҸ Ű + ̸ ־ Ѵ. ȱ ƹ Ʈ + . ˻غ <code>hosts</code> Ͽ + ߰ , ̴ hosts ǻͿ + ݿȴ.</p> + </div> + + <div class="example"><h3> </h3><p><code> + + + # ġ Ʈ 80 ٸ<br /> + Listen 80<br /> + <br /> + # IP ּҿ ȣƮ û ٸ<br /> + NameVirtualHost *:80<br /> + <br /> + <VirtualHost *:80><br /> + <span class="indent"> + DocumentRoot /www/example1<br /> + ServerName www.example.com<br /> + <br /> + # ٸ þ鵵 ִ<br /> + <br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost *:80><br /> + <span class="indent"> + DocumentRoot /www/example2<br /> + ServerName www.example.org<br /> + <br /> + # ٸ þ鵵 ִ<br /> + <br /> + </span> + </VirtualHost> + </code></p></div> + + <p>ǥ ּҸ ŰǷ, ּ û + ʴ´. <code>www.example.com</code> + Ͽ ó Ƿ 켱 , + <cite>⺻</cite>Ȥ <cite>ʱ</cite> ȴ. + <code>ServerName</code> þ شʴ û + ù° <code>VirtualHost</code> Ѵ.</p> + + <div class="note"> + <h3></h3> + + <p>Ѵٸ <code>*</code> ý IP + ּҸ ִ. + <code>VirtualHost</code> ƱԸƮ + <code>NameVirtualHost</code> ƱԸƮ ġؾ + <em>Ѵ</em>:</p> + + <div class="example"><p><code> + NameVirtualHost 172.20.30.40<br /> + <br /> + <VirtualHost 172.20.30.40><br /> + # ... + </code></p></div> + + <p> ISP IP ּҸ + IP ּҸ 쿡 <code>*</code> ϴ + ϴ. <code>*</code> IP ּҿ + شϹǷ, IP ּҰ Ǿ + ʿ䰡 .</p> + </div> + + <p> κ ̸ ȣƮ . + ܴ ٸ IP ּҳ Ʈ ٸ Ϸ + ̴.</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="twoips" id="twoips"> IP ּҿ ̸ + ȣƮ.</a></h2> + + <div class="note"> + <h3></h3><p>⼭ IP ּҰ + 밡ϴ.</p> + </div> + + <p> IP ּҰ ΰִ. ϳ + (<code>172.20.30.40</code>) "" + <code>server.domain.com</code> ϰ, ٸ ϳ + (<code>172.20.30.50</code>) ȣƮ + ̴.</p> + + <div class="example"><h3> </h3><p><code> + + + Listen 80<br /> + <br /> + # 172.20.30.40 ϴ ""̴<br /> + ServerName server.domain.com<br /> + DocumentRoot /www/mainserver<br /> + <br /> + # ٸ ּҴ<br /> + NameVirtualHost 172.20.30.50<br /> + <br /> + <VirtualHost 172.20.30.50><br /> + <span class="indent"> + DocumentRoot /www/example1<br /> + ServerName www.example.com<br /> + <br /> + # ٸ þ鵵 ִ ...<br /> + <br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.50><br /> + <span class="indent"> + DocumentRoot /www/example2<br /> + ServerName www.example.org<br /> + <br /> + # ٸ þ鵵 ִ ...<br /> + <br /> + </span> + </VirtualHost> + </code></p></div> + + <p><code>172.20.30.50</code> ƴ ּҿ û + ּ Ѵ. ȣƮ , <code>Host:</code> + <code>172.20.30.50</code> ûϸ + <code>www.example.com</code> Ѵ.</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="intraextra" id="intraextra">(ο ܺ ּҿ ) + ٸ IP ּҷ ϱ.</a></h2> + + <p> ǻͿ IP ּҰ ΰ (<code>192.168.1.1</code> + <code>172.20.30.40</code>) ִ. ǻʹ (Ʈ) + Ʈ ܺ (ͳ) Ʈ ̿ ġѴ. Ʈ ۿ + <code>server.example.com</code> ܺ ּҸ + (<code>172.20.30.40</code>) ǹϰ, Ʈ ο + ̸ ּҷ (<code>192.168.1.1</code>) Ѵ.</p> + + <p> <code>VirtualHost</code> Ѱ ο ܺ + 信 ִ.</p> + + <div class="example"><h3> </h3><p><code> + + + NameVirtualHost 192.168.1.1<br /> + NameVirtualHost 172.20.30.40<br /> + <br /> + <VirtualHost 192.168.1.1 172.20.30.40><br /> + <span class="indent"> + DocumentRoot /www/server1<br /> + ServerName server.example.com<br /> + ServerAlias server<br /> + </span> + </VirtualHost> + </code></p></div> + + <p> Ʈ û + <code>VirtualHost</code> Ѵ.</p> + + <div class="note"> + <h3>:</h3><p> Ʈ ȣƮ + <code>server.example.com</code> ̸ + <code>server</code> ϴ.</p> + + <p> IP ּ <code>*</code> + Ͽ ּҿ ϰ + ִ.</p> + </div> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="port" id="port"> Ʈ ٸ Ʈ + ϱ.</a></h2> + + <p> IP Ʈ ٸ Ѵٰ + . ̴ "NameVirtualHost" ± Ʈ ϸ + ϴ. NameVirtualHost name:port <VirtualHost + name:port> Ȥ Listen þ ϸ ȵȴ.</p> + + <div class="example"><h3> </h3><p><code> + + + Listen 80<br /> + Listen 8080<br /> + <br /> + NameVirtualHost 172.20.30.40:80<br /> + NameVirtualHost 172.20.30.40:8080<br /> + <br /> + <VirtualHost 172.20.30.40:80><br /> + <span class="indent"> + ServerName www.example.com<br /> + DocumentRoot /www/domain-80<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40:8080><br /> + <span class="indent"> + ServerName www.example.com<br /> + DocumentRoot /www/domain-8080<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40:80><br /> + <span class="indent"> + ServerName www.example.org<br /> + DocumentRoot /www/otherdomain-80<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40:8080><br /> + <span class="indent"> + ServerName www.example.org<br /> + DocumentRoot /www/otherdomain-8080<br /> + </span> + </VirtualHost> + </code></p></div> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="ip" id="ip">IP ȣƮ</a></h2> + + <p> <code>www.example.com</code> + <code>www.example.org</code> شϴ IP ּҸ + (<code>172.20.30.40</code> <code>172.20.30.50</code>) + .</p> + + <div class="example"><h3> </h3><p><code> + + + Listen 80<br /> + <br /> + <VirtualHost 172.20.30.40><br /> + <span class="indent"> + DocumentRoot /www/example1<br /> + ServerName www.example.com<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.50><br /> + <span class="indent"> + DocumentRoot /www/example2<br /> + ServerName www.example.org<br /> + </span> + </VirtualHost> + </code></p></div> + + <p><code><VirtualHost></code> þ ּҿ + شʴ ּҷ ( , <code>localhost</code>) + û ּ ִ ּ Ѵ.</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="ipport" id="ipport">Ʈݰ ip ȥյ + ȣƮ</a></h2> + + <p> <code>www.example.com</code> + <code>www.example.org</code> شϴ IP ּҸ + (<code>172.20.30.40</code> <code>172.20.30.50</code>) + . IP 80 8080 Ʈ ȣƮ .</p> + + <div class="example"><h3> </h3><p><code> + + + Listen 172.20.30.40:80<br /> + Listen 172.20.30.40:8080<br /> + Listen 172.20.30.50:80<br /> + Listen 172.20.30.50:8080<br /> + <br /> + <VirtualHost 172.20.30.40:80><br /> + <span class="indent"> + DocumentRoot /www/example1-80<br /> + ServerName www.example.com<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40:8080><br /> + <span class="indent"> + DocumentRoot /www/example1-8080<br /> + ServerName www.example.com<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.50:80><br /> + <span class="indent"> + DocumentRoot /www/example2-80<br /> + ServerName www.example.org<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.50:8080><br /> + <span class="indent"> + DocumentRoot /www/example2-8080<br /> + ServerName www.example.org<br /> + </span> + </VirtualHost> + </code></p></div> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="mixed" id="mixed"≯ݰ IP ȥյ + ȣƮ</a></h2> + + <p>ּ ̸ ȣƮ, ٸ IP + ȣƮ ϰ ʹ.</p> + + <div class="example"><h3> </h3><p><code> + + + Listen 80<br /> + <br /> + NameVirtualHost 172.20.30.40<br /> + <br /> + <VirtualHost 172.20.30.40><br /> + <span class="indent"> + DocumentRoot /www/example1<br /> + ServerName www.example.com<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40><br /> + <span class="indent"> + DocumentRoot /www/example2<br /> + ServerName www.example.org<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40><br /> + <span class="indent"> + DocumentRoot /www/example3<br /> + ServerName www.example3.net<br /> + </span> + </VirtualHost><br /> + <br /> + # IP-<br /> + <VirtualHost 172.20.30.50><br /> + <span class="indent"> + DocumentRoot /www/example4<br /> + ServerName www.example4.edu<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.60><br /> + <span class="indent"> + DocumentRoot /www/example5<br /> + ServerName www.example5.gov<br /> + </span> + </VirtualHost> + </code></p></div> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="default" id="default"><code>_default_</code> ȣƮ + ϱ</a></h2> + + <h3><a name="defaultallports" id="defaultallports"> Ʈ + <code>_default_</code> ȣƮ</a></h3> + + <p> ȣƮ ش IP ּҿ Ʈ + <em></em> û óϱ.</p> + + <div class="example"><h3> </h3><p><code> + + + <VirtualHost _default_:*><br /> + <span class="indent"> + DocumentRoot /www/default<br /> + </span> + </VirtualHost> + </code></p></div> + + <p>default(⺻) ȣƮ Ʈ ϵī带 Ͽ û + ּ .</p> + + <p>default ȣƮ ̸ ȣƮ ϴ + ּ/Ʈ û ʴ´. ų + <code>Host:</code> û ̸ + ȣƮ(Ͽ + ּ/Ʈ ó ȣƮ) Ѵ.</p> + + <p><code class="directive"><a href="../mod/mod_alias.html#aliasmatch">AliasMatch</a></code> + <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> + Ͽ û Ư (Ȥ ũƮ) + ۼ(rewrite) ִ.</p> + + + <h3><a name="defaultdifferentports" id="defaultdifferentports"> Ʈ + <code>_default_</code> ȣƮ</a></h3> + + <p> , Ʈ ٸ 80 + Ʈ ؼ ߰ <code>_default_</code> ȣƮ + ϰ ʹ.</p> + + <div class="example"><h3> </h3><p><code> + + + <VirtualHost _default_:80><br /> + <span class="indent"> + DocumentRoot /www/default80<br /> + # ...<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost _default_:*><br /> + <span class="indent"> + DocumentRoot /www/default<br /> + # ...<br /> + </span> + </VirtualHost> + </code></p></div> + + <p>80 Ʈ default ȣƮ (<em>ݵ</em> + ϵī Ʈ ⺻ ȣƮ ; Ѵ) + IP ּҷ û Ѵ. + ּ û Ѵ.</p> + + + <h3><a name="defaultoneport" id="defaultoneport"> Ʈ + <code>_default_</code> ȣƮ</a></h3> + + <p>80 Ʈ ؼ default ȣƮ ʹ.</p> + + <div class="example"><h3> </h3><p><code> + + + <VirtualHost _default_:80><br /> + DocumentRoot /www/default<br /> + ...<br /> + </VirtualHost> + </code></p></div> + + <p>Ʈ 80 ּҿ û ⺻ + ȣƮ ϰ, ٸ ּҿ Ʈ + û Ѵ.</p> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="migrate" id="migrate"≯ ȣƮ IP + ȣƮ ű</a></h2> + + <p>(<a href="#name"≯</a> ù° ) ȣƮ + <code>www.example.org</code> ̸ ȣƮ + ڽ IP ּҸ Ѵ. ̸ ȣƮ + IP ּҸ ijϴ Ӽ Ͻÿ ϱ + ű θ ϰ ʹ.</p> + + <p> + <code>VirtualHost</code> þ IP ּҸ + (<code>172.20.30.50</code>) ߰ϸǹǷ .</p> + + <div class="example"><h3> </h3><p><code> + + + Listen 80<br /> + ServerName www.example.com<br /> + DocumentRoot /www/example1<br /> + <br /> + NameVirtualHost 172.20.30.40<br /> + <br /> + <VirtualHost 172.20.30.40 172.20.30.50><br /> + <span class="indent"> + DocumentRoot /www/example2<br /> + ServerName www.example.org<br /> + # ...<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40><br /> + <span class="indent"> + DocumentRoot /www/example3<br /> + ServerName www.example.net<br /> + ServerAlias *.example.net<br /> + # ...<br /> + </span> + </VirtualHost> + </code></p></div> + + <p> (IP ȣƮ ) ο ּҿ (̸ + ȣƮ ) ּ ȣƮ + ִ.</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="serverpath" id="serverpath"><code>ServerPath</code> + þ ϱ</a></h2> + + <p> ̸ ȣƮ ִ. ùٸ + ȣƮ ϱ Ŭ̾Ʈ ùٸ + <code>Host:</code> Ѵ. HTTP/1.0 + Ŭ̾Ʈ ϸ ġ Ŭ̾Ʈ + ȣƮ ϴ ( + ȣƮ û Ѵ). ȣȯ + ϱ ȣƮ , ̸ + ȣƮ URL λ縦 ϴ ũ + д.</p> + + <div class="example"><h3> </h3><p><code> + + + NameVirtualHost 172.20.30.40<br /> + <br /> + <VirtualHost 172.20.30.40><br /> + <span class="indent"> + # primary vhost<br /> + DocumentRoot /www/subdomain<br /> + RewriteEngine On<br /> + RewriteRule ^/.* /www/subdomain/index.html<br /> + # ...<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40><br /> + DocumentRoot /www/subdomain/sub1<br /> + <span class="indent"> + ServerName www.sub1.domain.tld<br /> + ServerPath /sub1/<br /> + RewriteEngine On<br /> + RewriteRule ^(/sub1/.*) /www/subdomain$1<br /> + # ...<br /> + </span> + </VirtualHost><br /> + <br /> + <VirtualHost 172.20.30.40><br /> + <span class="indent"> + DocumentRoot /www/subdomain/sub2<br /> + ServerName www.sub2.domain.tld<br /> + ServerPath /sub2/<br /> + RewriteEngine On<br /> + RewriteRule ^(/sub2/.*) /www/subdomain$1<br /> + # ...<br /> + </span> + </VirtualHost> + </code></p></div> + + <p><code class="directive"><a href="../mod/core.html#serverpath">ServerPath</a></code> þ + URL <code>http://www.sub1.domain.tld/sub1/</code> + û <em></em> subl-ȣƮ Ѵ.<br /> + Ŭ̾Ʈ ùٸ <code>Host:</code> ٸ, + URL <code>http://www.sub1.domain.tld/</code> û + subl-ȣƮ Ѵ. <code>Host:</code> + Ŭ̾Ʈ ȣƮ ִ + Եȴ.</p> + + <p> ϶: Ŭ̾Ʈ + <code>Host:</code> + <code>http://www.sub2.domain.tld/sub1/</code> û + subl-ȣƮ Ѵ.</p> + + <p><code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> + þ Ͽ ùٸ <code>Host:</code> + Ŭ̾Ʈ (<em> </em>, URL ġ簡 ְų ) + URL ִ.</p> + + </div></div> +<div class="bottomlang"> +<p><span> : </span><a href="../en/vhosts/examples.html" hreflang="en" rel="alternate" title="English"> en </a> | +<a href="../fr/vhosts/examples.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | +<a href="../ja/vhosts/examples.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | +<a href="../ko/vhosts/examples.html" title="Korean"> ko </a> | +<a href="../tr/vhosts/examples.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> +</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">Comments</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 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 Libera.chat, or sent to our <a href="https://httpd.apache.org/lists.html">mailing lists</a>.</div> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/vhosts/examples.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> +<p class="apache">Copyright 2023 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> +<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[//><!-- +if (typeof(prettyPrint) !== 'undefined') { + prettyPrint(); +} +//--><!]]></script> +</body></html>
\ No newline at end of file diff --git a/docs/manual/vhosts/examples.html.tr.utf8 b/docs/manual/vhosts/examples.html.tr.utf8 new file mode 100644 index 0000000..d5c620d --- /dev/null +++ b/docs/manual/vhosts/examples.html.tr.utf8 @@ -0,0 +1,562 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="tr" xml:lang="tr"><head> +<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> +<!-- + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + This file is generated from xml source: DO NOT EDIT + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + --> +<title>Sanal Konak Örnekleri - Apache HTTP Sunucusu Sürüm 2.4</title> +<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> +<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> +<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" /> +<script src="../style/scripts/prettify.min.js" type="text/javascript"> +</script> + +<link href="../images/favicon.ico" rel="shortcut icon" /></head> +<body id="manual-page"><div id="page-header"> +<p class="menu"><a href="../mod/">Modüller</a> | <a href="../mod/directives.html">Yönergeler</a> | <a href="http://wiki.apache.org/httpd/FAQ">SSS</a> | <a href="../glossary.html">Terimler</a> | <a href="../sitemap.html">Site Haritası</a></p> +<p class="apache">Apache HTTP Sunucusu Sürüm 2.4</p> +<img alt="" src="../images/feather.png" /></div> +<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> +<div id="path"> +<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Sunucusu</a> > <a href="http://httpd.apache.org/docs/">Belgeleme</a> > <a href="../">Sürüm 2.4</a> > <a href="./">Sanal Konaklar</a></div><div id="page-content"><div id="preamble"><h1>Sanal Konak Örnekleri</h1> +<div class="toplang"> +<p><span>Mevcut Diller: </span><a href="../en/vhosts/examples.html" hreflang="en" rel="alternate" title="English"> en </a> | +<a href="../fr/vhosts/examples.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | +<a href="../ja/vhosts/examples.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | +<a href="../ko/vhosts/examples.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | +<a href="../tr/vhosts/examples.html" title="Türkçe"> tr </a></p> +</div> + + + <p>Bu belgede <a href="index.html">sanal konaklarla</a> ile ilgili olarak + karşılaşılması olası tüm senaryolara yer verilmeye çalışılmıştır. + Buradaki senaryolar, tek bir sunucu üzerinde <a href="name- based.html">isme dayalı</a> veya <a href="ip-based.html">IP’ye dayalı</a> + sanal konaklar aracılığıyla çok sayıda sitenin sunumu ile ilgilidir. + </p> + +</div> +<div id="quickview"><a href="https://www.apache.org/foundation/contributing.html" class="badge"><img src="https://www.apache.org/images/SupportApache-small.png" alt="Support Apache!" /></a><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#purename">Tek bir IP ile çok sayıda isme dayalı site</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#twoips">IP adresleri farklı çok sayıda isme dayalı site</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#intraextra">Aynı içeriği farklı IP adresleriyle sunmak + (örn., dahili ve harici ağlara)</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#port">Farklı portlarla farklı siteler</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#ip">IP’ye dayalı sanal konaklar</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#ipport">Hem IP’ye hem de porta dayalı sanal konaklar</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#mixed">Hem isme hem de IP‘ye dayalı sanal konaklar</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#proxy"><code>Virtualhost</code> ve + <code>mod_proxy</code>’nin birlikte kullanımı</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#default"><code>_default_</code> sanal konakları</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#migrate">Bir isme dayalı sanal konağı bir IP’ye dayalı + sanal konakla yansılamak</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#serverpath"><code>ServerPath</code> yönergesinin kullanımı</a></li> +</ul><h3>Ayrıca bakınız:</h3><ul class="seealso"><li><a href="#comments_section">Yorumlar</a></li></ul></div> +<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="purename" id="purename">Tek bir IP ile çok sayıda isme dayalı site</a></h2> + + + <p>Bu örnekte, makinenizin tek bir IP adresine çözümlenen çok sayıda konak + adına sahip olduğunu, <code>example.com</code> ve + <code>example.org</code> gibi farklı isimlere farklı yanıtlar vermek + istediğinizi varsayalım.</p> + + <div class="note"><h3>Bilginize</h3><p>Apache sunucusu üzerinde sanal konakları + yapılandırmakla bu konak isimleri için sihirli bir şekilde DNS + kayıtlarının da oluşturulmasını sağlamış olmazsınız. Bu isimler için + ilgili DNS kayıtlarında sizin IP adresinize çözümlenen A kayıtlarının + olması gerekir, yoksa sitenize kimse erişemez. Sitelere erişimi yerel + olarak denemek isterseniz, bu girdileri <code>hosts</code> dosyanıza + yazabilirsiniz. Fakat bu sadece sizin makinenizde çalışır. Yerel + ağınızdaki her makinenin <code>hosts</code> dosyasına bu girdileri + yazarak yerel ağdan erişimi bu yolla sağlayabilirsiniz ama dış ağdan + gelecek ziyaretçileriniz için DNS kayıtlarınızın olması şarttır.</p> + </div> + + <pre class="prettyprint lang-config"># Apache’nin 80. portu dinlediğinden emin olalım +Listen 80 +<VirtualHost *:80> + DocumentRoot "/siteler/ecom" + ServerName example.com + + # Diğer yönergeler, burada ... +</VirtualHost> + +<VirtualHost *:80> + DocumentRoot "/siteler/eorg" + ServerName example.org + + # Diğer yönergeler, burada ... +</VirtualHost></pre> + + + <p>Yıldız imleri tüm adreslerle eşleşmeyi sağladığından ana sunucu + (yapılandırma dosyası genelindeki yapılandırma - sunucu geneli) + erişilebilir olmayacaktır. Yapılandırma + dosyasındaki <code>ServerName example.com</code> yönergeli konak, ilk + sanal konak olduğundan en yüksek önceliğe sahiptir ve + <cite>öntanımlı</cite> veya <cite>baskın</cite> site olarak davranır. + Yani, hiçbir <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code> yönergesi + ile eşleşmeyen bir istek alındığında bu istek ilk <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> yapılandırması ile + karşılanır.</p> + + <p>Yukarıdaki yapılandırmayı hemen hemen tüm isme dayalı sanal konaklar + için kullanabilirsiniz. Bu yapılandırmanın çalışmayacağı tek durum, + farklı içerikleri farklı IP adres veya portlardan sunma gereğiyle + karşılaşmaktır.</p> + + <div class="note"><h3>Bilginize</h3> + <p><code>*</code> yerine sisteminizdeki belli bir IP adresini + yazabilirsiniz. Böyle sanal konaklar sadece, HTTP isteklerinin sadece + belirtilen IP adreslerinden alınması için kullanilabilir.</p> + + <pre class="prettyprint lang-config">NameVirtualHost 192.168.1.22 + +<VirtualHost 192.168.1.22> + # vs. ... +</VirtualHost></pre> + + + <p>Bununla birlikte, IP adresinin önceden kestirilebilir olmadığı + sistemlerde, örneğin, hizmet sağlayıcınıza çevirmeli ağ ile bağlanıyor + ve onun rasgele atadığı bir IP adresi için bir devingen DNS çözümü + kullanıyorsanız, IP adresi değil de <code>*</code> kullanmak daha çok + işinize yarayacaktır. Yıldız imi her IP adresi ile eşleşeceğinden IP + adresiniz değişse bile bu yapılandırmayı değiştirmeden + kullanabilirsiniz.</p> + </div> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="twoips" id="twoips">IP adresleri farklı çok sayıda isme dayalı site</a></h2> + + + <div class="note"><h3>Bilginize</h3> + <p>Burada açıklanan teknikler istendiği kadar çok IP adresine + genişletilebilir.</p> + </div> + + <p>Sunucunun iki IP adresi olsun. Birinden "ana sunucu" + (<code>192.168.1.2</code>) diğerinden <code>example.com</code> + <code>192.168.2.2</code> hizmet versin. Bu arada başka sanal konakları + da sunabilelim istiyoruz.</p> + + <pre class="prettyprint lang-config">Listen 80 + +# Bu, 192.168.1.2 adresindeki "ana sunucu" olsun +ServerName sunucu.example.com +DocumentRoot "/siteler/anasunucu" + +<VirtualHost 192.168.1.20> + DocumentRoot "/siteler/ecom" + ServerName example.com + + # Diğer yönergeler, burada ... +</VirtualHost> + +<VirtualHost 192.168.1.20> + DocumentRoot "/siteler/eorg" + ServerName example.org + + # Diğer yönergeler, burada ... +</VirtualHost></pre> + + + <p><code>192.168.1.20</code> adresinden gelmeyen tüm isteklere ana sunucu + (<code>sunucu.example.com</code>), <code>192.168.1.20</code> adresinden + gelen sunucu ismi belirtmeyenler ile <code>Host:</code> başlığı + belirtmeyenlere ise <code>example.com</code> hizmet verecektir.</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="intraextra" id="intraextra">Aynı içeriği farklı IP adresleriyle sunmak + (örn., dahili ve harici ağlara)</a></h2> + + <p>Sunucu makine iki IP adresine sahip olsun. Biri iç ağa + (<code>192.168.1.1</code>) diğeri dış ağa (<code>172.20.30.40</code>) + bakıyor olsun. <code>sunucu.example.com</code> ismi dış ağda dış ağa + bakan IP’ye, iç ağda ise iç ağa bakan IP’ye çözümleniyor olsun.</p> + + <p>Bu durumda, sunucu hem iç hem de dış ağdan gelen isteklere aynı içerik, + dolayısıyla aynı <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> bölümü ile hizmet verebilir.</p> + + <pre class="prettyprint lang-config"><VirtualHost 192.168.1.1 172.20.30.40> + DocumentRoot "/siteler/sunucu" + ServerName sunucu.example.com + ServerAlias sunucu +</VirtualHost></pre> + + + <p>Artık, hem iç hem de dış ağdan gelen isteklere aynı + <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> + bölümünden hizmet sunulacaktır.</p> + + <div class="note"><h3>Bilginize:</h3> + <p>İç ağdan istek yapan biri, tam nitelenmiş konak ismi + <code>sunucu.example.com</code> yerine makine ismini + (<code>sunucu</code>) kullanabilir (<code>ServerAlias sunucu</code> + satırına dikkat).</p> + + <p>Ayrıca, yukarıdaki gibi iki ayrı IP adresi belirtmek yerine sadece + <code>*</code> belirtmekle sunucunun tüm IP adreslerine yine aynı + içerikle yanıt vereceğine dikkat ediniz.</p> + </div> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="port" id="port">Farklı portlarla farklı siteler</a></h2> + + <p>Aynı IP adresine sahip çok sayıda konak ismine sahip olduğunuzu ve + bunların bazılarının farklı portları kullanmasını istediğinizi + varsayalım. Aşağıdaki örnekte, isim eşleşmesinin, en iyi eşleşen IP + adresi ve port çifti saptandıktan sonra yer alması gösterilmiştir. </p> + + <pre class="prettyprint lang-config">Listen 80 +Listen 8080 + +<VirtualHost 172.20.30.40:80> + ServerName example.com + DocumentRoot "/siteler/ecom-80" +</VirtualHost> + +<VirtualHost 172.20.30.40:8080> + ServerName example.com + DocumentRoot "/siteler/ecom-8080" +</VirtualHost> + +<VirtualHost 172.20.30.40:80> + ServerName example.org + DocumentRoot "/siteler/eorg-80" +</VirtualHost> + +<VirtualHost 172.20.30.40:8080> + ServerName example.org + DocumentRoot "/siteler/eorg-8080" +</VirtualHost></pre> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="ip" id="ip">IP’ye dayalı sanal konaklar</a></h2> + + <p>Sunucu makinenin, biri <code>example.com</code> adından çözümlenen + <code>172.20.30.40</code>, diğeri <code>example.org</code> adından + çözümlenen <code>172.20.30.50</code> diye iki IP adresi olsun.</p> + + <pre class="prettyprint lang-config">Listen 80 + +<VirtualHost 172.20.30.40> + DocumentRoot "/siteler/ecom" + ServerName example.com +</VirtualHost> + +<VirtualHost 172.20.30.50> + DocumentRoot "/siteler/eorg" + ServerName example.org +</VirtualHost></pre> + + + <p><code><VirtualHost></code> yönergelerinde belirtilmeyen + adreslerle yapılan isteklere (örneğin, <code>localhost</code>) sunucu + genelindeki yapılandırma ile ana sunucu yanıt verecektir.</p> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="ipport" id="ipport">Hem IP’ye hem de porta dayalı sanal konaklar</a></h2> + + + <p>Sunucu makinenin, biri <code>example.com</code> adından çözümlenen + <code>172.20.30.40</code>, diğeri <code>example.org</code> adından + çözümlenen <code>172.20.30.50</code> diye iki IP adresi olsun ve iki + konak da hem 80 hem de 8080 portlarında çalışsınlar istiyoruz.</p> + + <pre class="prettyprint lang-config">Listen 172.20.30.40:80 +Listen 172.20.30.40:8080 +Listen 172.20.30.50:80 +Listen 172.20.30.50:8080 + +<VirtualHost 172.20.30.40:80> + DocumentRoot "/siteler/ecom-80" + ServerName example.com +</VirtualHost> + +<VirtualHost 172.20.30.40:8080> + DocumentRoot "/siteler/ecom-8080" + ServerName example.com +</VirtualHost> + +<VirtualHost 172.20.30.50:80> + DocumentRoot "/siteler/eorg-80" + ServerName example.org +</VirtualHost> + +<VirtualHost 172.20.30.50:8080> + DocumentRoot "/siteler/eorg-8080" + ServerName example.org +</VirtualHost></pre> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="mixed" id="mixed">Hem isme hem de IP‘ye dayalı sanal konaklar</a></h2> + + + <p>Bir <code>VirtualHost</code> yönergesinde belirtilen bir IP adresi başka + bir sanal konakta görünmüyorsa bu sankon kesinlikle IP'ye dayalı bir + sanal konaktır.</p> + + <pre class="prettyprint lang-config">Listen 80 + +<VirtualHost 172.20.30.40> + DocumentRoot "/siteler/ecom" + ServerName example.com +</VirtualHost> + +<VirtualHost 172.20.30.40> + DocumentRoot "/siteler/eorg" + ServerName example.org +</VirtualHost> + +<VirtualHost 172.20.30.40> + DocumentRoot "/siteler/enet" + ServerName example.net +</VirtualHost> + +# IP'ye dayalı +<VirtualHost 172.20.30.50> + DocumentRoot "/siteler/eedu" + ServerName example.edu +</VirtualHost> + +<VirtualHost 172.20.30.60> + DocumentRoot "/siteler/egov" + ServerName example.gov +</VirtualHost></pre> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="proxy" id="proxy"><code>Virtualhost</code> ve + <code>mod_proxy</code>’nin birlikte kullanımı</a></h2> + + <p>Bu örnekte bir arabirimi dışarıya bakan bir makinede, başka bir + makinede çalışan bir sunucuya sanal konak olarak, bir vekil sunucu + çalıştırmak istediğimizi varsayıyoruz. <code>192.168.111.2</code> IP + adresli bir makinede aynı isimde bir sanal konak yapılandırılmış olsun. + Çok sayıda konak ismi için vekil olarak tek bir makine kullandığımızdan + ve konak isminin de aktarılmasını arzuladığımızdan <code class="directive"><a href="../mod/mod_proxy.html#proxypreservehost">ProxyPreserveHost + On</a></code> yönergesini kullandık.</p> + + <pre class="prettyprint lang-config"><VirtualHost *:*> + ProxyPreserveHost On + ProxyPass "/" "http://192.168.111.2/" + ProxyPassReverse "/" "http://192.168.111.2/" + ServerName konak.example.com +</VirtualHost></pre> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="default" id="default"><code>_default_</code> sanal konakları</a></h2> + + <h3><a name="defaultallports" id="defaultallports">Tüm portlar için <code>_default_</code></a></h3> + + + <p>Bir IP adresi ve port belirtilmeyen veya hiçbir sanal konağın hiçbir + adresi/portu ile eşleşmeyen istekleri yakalamak istersek...</p> + + <pre class="prettyprint lang-config"><VirtualHost _default_:*> + DocumentRoot "/siteler/default" +</VirtualHost></pre> + + + <p>Bütün portlarla eşleşen böyle bir öntanımlı sanal konağın kullanımı + hiçbir isteğin ana sunucuya gitmemesi sonucunu doğurur.</p> + + <p>Bir öntanımlı sanal konak, asla, isme dayalı sanal konaklar için + kullanılmış bir adrese/porta gönderilmiş bir isteğe hizmet sunmaz. Eğer + istek bilinmeyen bir <code>Host:</code> başlığına sahipse veya hiç + <code>Host:</code> başlığı içermiyorsa isteğe daima ilk (yapılandırma + dosyasındaki ilk) isme dayalı sanal konak hizmet sunar.</p> + + <p>Her isteği tek bir bilgilendirme sayfasına (veya betiğe) yönlendirmek + isterseniz <code class="directive"><a href="../mod/mod_alias.html#aliasmatch">AliasMatch</a></code> veya + <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> yönergesini + kullanabilirsiniz.</p> + + + <h3><a name="defaultdifferentports" id="defaultdifferentports">Farklı portlardan <code>_default_</code></a></h3> + + + <p>Önceki yapılandırmaya ek olarak 80. portta ayrı bir + <code>_default_</code> sanal konağı kullanmak istersek...</p> + + <pre class="prettyprint lang-config"><VirtualHost _default_:80> + DocumentRoot "/siteler/default80" + # ... +</VirtualHost> + +<VirtualHost _default_:*> + DocumentRoot "/siteler/default" + # ... +</VirtualHost></pre> + + + <p>80. porttan hizmet sunan <code>_default_</code> sanal konağı IP adresi + belirtilmeyen tüm istekleri yakalar, bunu yapabilmesi için yapılandırma + dosyasında tüm portlara hizmet sunan benzerinden önce yer almalıdır. Bu + durumda ana sunucu hiçbir isteğe yanıt vermeyecektir.</p> + + + <h3><a name="defaultoneport" id="defaultoneport">Tek portluk <code>_default_</code></a></h3> + + + <p><code>_default_</code> sanal konağının sadece 80. porttan hizmet + sunmasını istersek...</p> + + <pre class="prettyprint lang-config"><VirtualHost _default_:80> + DocumentRoot "/siteler/default" + ... +</VirtualHost></pre> + + + <p>80. porttan gelen IP adresi belirtilmemiş isteklere + <code>_default_</code> sanal konağı, diğer portlardan gelen adres + belirtilmemiş isteklere ise ana sunucu hizmet verecektir.</p> + + <p>Bir sanal konak bildiriminde <code>*</code> kullanımı + <code>_default_</code> kullanımından daha yüksek öncelik sağlar.</p> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="migrate" id="migrate">Bir isme dayalı sanal konağı bir IP’ye dayalı + sanal konakla yansılamak</a></h2> + + <p>İsme dayalı sanal konak örneklerinin <a href="#twoips">2. sinde</a> adı + geçen <code>example.org</code> bu örnekte kendi IP adresinden hizmet + veriyor olsun. İsme dayalı sanal konağı eski IP adresiyle kaydetmiş + vekiller ve isim sunucularından kaynaklanacak olası sorunlardan kaçınmak + için yansılama sırasında sanal konağı hem eski hem de yeni IP adresiyle + sunmamız lazım.</p> + + <p>Çözüm kolay, çünkü yapacağımız sadece <code>VirtualHost</code> + yönergesine yeni IP adresini (<code>192.168.1.2</code>) eklemek + olacak.</p> + + <pre class="prettyprint lang-config">Listen 80 +ServerName example.com +DocumentRoot "/siteler/ecom" + +<VirtualHost 192.168.1.20 192.168.1.2> + DocumentRoot "/siteler/eorg" + ServerName example.org + # ... +</VirtualHost> + +<VirtualHost 192.168.1.20> + DocumentRoot "/siteler/enet" + ServerName example.enet + ServerAlias *.example.net + # ... +</VirtualHost></pre> + + + <p>Böylece sanal konağa hem yeni (bir IP’ye dayalı sanal konak olarak) + hem de eski adresinden (bir isme dayalı sanal konak olarak) + erişilebilecektir.</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="serverpath" id="serverpath"><code>ServerPath</code> yönergesinin kullanımı</a></h2> + + + <p>İsme dayalı iki sanal konağı olan bir sunucumuz olsun. Doğru sanal + konağa erişebilmek için istemcinin doğru <code>Host:</code> başlığı + göndermesi gerekir. Eski HTTP/1.0 istemcileri böyle bir başlık + göndermedikleri için Apache istemcinin hangi sanal konağa erişmek + istediğini bilemez (ve isteğe ilk sanal konaktan hizmet sunar). Daha iyi + bir geriye uyumluluk sağlamak için isme dayalı sanal konağa bir önek + bağlantısı içeren bir bilgilendirme sayfası sunmak üzere yeni bir sanal + konak oluşturabiliriz.</p> + + <pre class="prettyprint lang-config"><VirtualHost 172.20.30.40> + # ilk sanal konak + DocumentRoot "/siteler/baska" + RewriteEngine On + RewriteRule "." "/siteler/baska/index.html" + # ... +</VirtualHost> + +<VirtualHost 172.20.30.40> + DocumentRoot /siteler/baska/bir + ServerName "bir.baska.tld" + ServerPath "/bir/" + RewriteEngine On + RewriteRule "^(/bir/.*) /siteler/baska$1" + # ... +</VirtualHost> + +<VirtualHost 172.20.30.40> + DocumentRoot "/siteler/baska/iki" + ServerName iki.baska.tld + ServerPath "/iki/" + RewriteEngine On + RewriteRule "^(/iki/.*)" "/siteler/baska$1" + # ... +</VirtualHost></pre> + + + <p><code class="directive"><a href="../mod/core.html#serverpath">ServerPath</a></code> yönergesinden dolayı + <code>http://bir.baska.tld/bir/</code> şeklinde yapılan isteklere + <em>daima</em> “bir” sanal konağı hizmet sunacaktır.</p> + + <p><code>http://bir.baska.tld/</code> şeklinde yapılan isteklere ise + istemcinin doğru <code>Host:</code> başlığı göndermesi şartıyla + “bir” sanal konağı hizmet sunacaktır. İstemci, bir + <code>Host:</code> başlığı göndermediği takdirde ilk konaktan bir + bilgilendirme sayfası alacaktır.</p> + + <p>Yalnız buradaki bir tuhaflığa dikkat edin: Eğer istemci bir + <code>Host:</code> başlığı göndermeden + <code>http://iki.baska.tld/bir/</code> şeklinde bir istek yaparsa bu + isteğe de “bir” sanal konağı hizmet sunacaktır.</p> + + <p><code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> yönergesi, bir + istemcinin, bir URL öneki belirtsin ya da belirtmesin doğru + <code>Host:</code> başlığı gönderdiğinden emin olmak için + kullanılmıştır.</p> + + </div></div> +<div class="bottomlang"> +<p><span>Mevcut Diller: </span><a href="../en/vhosts/examples.html" hreflang="en" rel="alternate" title="English"> en </a> | +<a href="../fr/vhosts/examples.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | +<a href="../ja/vhosts/examples.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | +<a href="../ko/vhosts/examples.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | +<a href="../tr/vhosts/examples.html" title="Türkçe"> tr </a></p> +</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">Yorumlar</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 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 Libera.chat, or sent to our <a href="https://httpd.apache.org/lists.html">mailing lists</a>.</div> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/vhosts/examples.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> +<p class="apache">Copyright 2023 The Apache Software Foundation.<br /><a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a> altında lisanslıdır.</p> +<p class="menu"><a href="../mod/">Modüller</a> | <a href="../mod/directives.html">Yönergeler</a> | <a href="http://wiki.apache.org/httpd/FAQ">SSS</a> | <a href="../glossary.html">Terimler</a> | <a href="../sitemap.html">Site Haritası</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- +if (typeof(prettyPrint) !== 'undefined') { + prettyPrint(); +} +//--><!]]></script> +</body></html>
\ No newline at end of file |