github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_2_34/manual/vhosts/ip-based.html.en (about) 1 <?xml version="1.0" encoding="ISO-8859-1"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head> 4 <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" /> 5 <!-- 6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 7 This file is generated from xml source: DO NOT EDIT 8 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 9 --> 10 <title>Apache IP-based Virtual Host Support - Apache HTTP Server Version 2.2</title> 11 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> 12 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> 13 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> 14 <script src="../style/scripts/prettify.min.js" type="text/javascript"> 15 </script> 16 17 <link href="../images/favicon.ico" rel="shortcut icon" /><link href="http://httpd.apache.org/docs/current/vhosts/ip-based.html" rel="canonical" /></head> 18 <body id="manual-page"><div id="page-header"> 19 <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> 20 <p class="apache">Apache HTTP Server Version 2.2</p> 21 <img alt="" src="../images/feather.gif" /></div> 22 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> 23 <div id="path"> 24 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a> > <a href="./">Virtual Hosts</a></div><div id="page-content"><div class="retired"><h4>Please note</h4> 25 <p> This document refers to a legacy release (<strong>2.2</strong>) of Apache httpd. The active release (<strong>2.4</strong>) is documented <a href="http://httpd.apache.org/docs/current">here</a>. If you have not already upgraded, please follow <a href="http://httpd.apache.org/docs/current/upgrading.html">this link</a> for more information.</p> 26 <p>You may follow <a href="http://httpd.apache.org/docs/current/vhosts/ip-based.html">this link</a> to go to the current version of this document.</p></div><div id="preamble"><h1>Apache IP-based Virtual Host Support</h1> 27 <div class="toplang"> 28 <p><span>Available Languages: </span><a href="../en/vhosts/ip-based.html" title="English"> en </a> | 29 <a href="../fr/vhosts/ip-based.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | 30 <a href="../ja/vhosts/ip-based.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | 31 <a href="../ko/vhosts/ip-based.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | 32 <a href="../tr/vhosts/ip-based.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> 33 </div> 34 </div> 35 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#explanation">What is IP-based virtual hosting</a></li> 36 <li><img alt="" src="../images/down.gif" /> <a href="#requirements">System requirements</a></li> 37 <li><img alt="" src="../images/down.gif" /> <a href="#howto">How to set up Apache</a></li> 38 <li><img alt="" src="../images/down.gif" /> <a href="#multiple">Setting up multiple daemons</a></li> 39 <li><img alt="" src="../images/down.gif" /> <a href="#single">Setting up a single daemon 40 with virtual hosts</a></li> 41 </ul><h3>See also</h3><ul class="seealso"><li> 42 <a href="name-based.html">Name-based Virtual Hosts Support</a> 43 </li></ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div> 44 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 45 <div class="section"> 46 <h2><a name="explanation" id="explanation">What is IP-based virtual hosting</a></h2> 47 <p>IP-based virtual hosting is a method to apply different directives 48 based on the IP address and port a request is received on. Most commonly, 49 this is used to serve different websites on different ports or interfaces.</p> 50 51 <p>In many cases, <a href="name-based.html">name-based 52 virtual hosts</a> are more convenient, because they allow 53 many virtual hosts to share a single address/port. 54 See <a href="name-based.html#namevip">Name-based vs. IP-based 55 Virtual Hosts</a> to help you decide. </p> 56 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 57 <div class="section"> 58 <h2><a name="requirements" id="requirements">System requirements</a></h2> 59 60 <p>As the term <cite>IP-based</cite> indicates, the server 61 <strong>must have a different IP address/port combination for each IP-based 62 virtual host</strong>. This can be achieved by the machine 63 having several physical network connections, or by use of 64 virtual interfaces which are supported by most modern operating 65 systems (see system documentation for details, these are 66 frequently called "ip aliases", and the "ifconfig" command is 67 most commonly used to set them up), and/or using multiple 68 port numbers.</p> 69 70 <p> In the terminology of Apache HTTP Server, using a single IP address 71 but multiple TCP ports, is also IP-based virtual hosting.</p> 72 73 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 74 <div class="section"> 75 <h2><a name="howto" id="howto">How to set up Apache</a></h2> 76 77 <p>There are two ways of configuring apache to support multiple 78 hosts. Either by running a separate <code class="program"><a href="../programs/httpd.html">httpd</a></code> daemon for 79 each hostname, or by running a single daemon which supports all the 80 virtual hosts.</p> 81 82 <p>Use multiple daemons when:</p> 83 84 <ul> 85 <li>There are security partitioning issues, such as company1 86 does not want anyone at company2 to be able to read their 87 data except via the web. In this case you would need two 88 daemons, each running with different <code class="directive"><a href="../mod/mpm_common.html#user">User</a></code>, <code class="directive"><a href="../mod/mpm_common.html#group">Group</a></code>, <code class="directive"><a href="../mod/mpm_common.html#listen">Listen</a></code>, and <code class="directive"><a href="../mod/core.html#serverroot">ServerRoot</a></code> settings.</li> 89 90 <li>You can afford the memory and file descriptor 91 requirements of listening to every IP alias on the 92 machine. It's only possible to <code class="directive"><a href="../mod/mpm_common.html#listen">Listen</a></code> to the "wildcard" 93 address, or to specific addresses. So if you have a need to 94 listen to a specific address for whatever reason, then you 95 will need to listen to all specific addresses. (Although one 96 <code class="program"><a href="../programs/httpd.html">httpd</a></code> could listen to N-1 of the addresses, and another could 97 listen to the remaining address.)</li> 98 </ul> 99 100 <p>Use a single daemon when:</p> 101 102 <ul> 103 <li>Sharing of the httpd configuration between virtual hosts 104 is acceptable.</li> 105 106 <li>The machine services a large number of requests, and so 107 the performance loss in running separate daemons may be 108 significant.</li> 109 </ul> 110 111 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 112 <div class="section"> 113 <h2><a name="multiple" id="multiple">Setting up multiple daemons</a></h2> 114 115 <p>Create a separate <code class="program"><a href="../programs/httpd.html">httpd</a></code> installation for each 116 virtual host. For each installation, use the <code class="directive"><a href="../mod/mpm_common.html#listen">Listen</a></code> directive in the 117 configuration file to select which IP address (or virtual host) 118 that daemon services. e.g.</p> 119 120 <div class="example"><p><code> 121 Listen 192.168.0.1:80 122 </code></p></div> 123 124 <p>It is recommended that you use an IP address instead of a 125 hostname (see <a href="../dns-caveats.html">DNS caveats</a>).</p> 126 127 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 128 <div class="section"> 129 <h2><a name="single" id="single">Setting up a single daemon 130 with virtual hosts</a></h2> 131 132 <p>For this case, a single <code class="program"><a href="../programs/httpd.html">httpd</a></code> will service 133 requests for the main server and all the virtual hosts. The <code class="directive"><a href="../mod/core.html#virtualhost">VirtualHost</a></code> directive 134 in the configuration file is used to set the values of <code class="directive"><a href="../mod/core.html#serveradmin">ServerAdmin</a></code>, <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code>, <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>, <code class="directive"><a href="../mod/core.html#errorlog">ErrorLog</a></code> and <code class="directive"><a href="../mod/mod_log_config.html#transferlog">TransferLog</a></code> 135 or <code class="directive"><a href="../mod/mod_log_config.html#customlog">CustomLog</a></code> 136 configuration directives to different values for each virtual 137 host. e.g.</p> 138 139 <div class="example"><p><code> 140 <VirtualHost 192.168.0.1:80><br /> 141 ServerAdmin webmaster@smallco.example.com<br /> 142 DocumentRoot /groups/smallco/www<br /> 143 ServerName smallco.example.com<br /> 144 ErrorLog /groups/smallco/logs/error_log<br /> 145 TransferLog /groups/smallco/logs/access_log<br /> 146 </VirtualHost><br /> 147 <br /> 148 <VirtualHost 192.168.0.2:80><br /> 149 ServerAdmin webmaster@baygroup.example.org<br /> 150 DocumentRoot /groups/baygroup/www<br /> 151 ServerName baygroup.example.com<br /> 152 ErrorLog /groups/baygroup/logs/error_log<br /> 153 TransferLog /groups/baygroup/logs/access_log<br /> 154 </VirtualHost> 155 </code></p></div> 156 157 <p>It is recommended that you use an IP address instead of a 158 hostname in the <VirtualHost> directive 159 (see <a href="../dns-caveats.html">DNS caveats</a>).</p> 160 161 <p> Specific IP addresses or ports have precedence over their wildcard 162 equivalents, and any virtual host that matches has precedence over 163 the servers base configuration.</p> 164 165 <p>Almost <strong>any</strong> configuration directive can be 166 put in the VirtualHost directive, with the exception of 167 directives that control process creation and a few other 168 directives. To find out if a directive can be used in the 169 VirtualHost directive, check the <a href="../mod/directive-dict.html#Context">Context</a> using the 170 <a href="../mod/directives.html">directive index</a>.</p> 171 172 <p><code class="directive"><a href="../mod/mod_suexec.html#suexecusergroup">SuexecUserGroup</a></code> 173 may be used inside a 174 VirtualHost directive if the <a href="../suexec.html">suEXEC 175 wrapper</a> is used.</p> 176 177 <p><em>SECURITY:</em> When specifying where to write log files, 178 be aware of some security risks which are present if anyone 179 other than the user that starts Apache has write access to the 180 directory where they are written. See the <a href="../misc/security_tips.html">security tips</a> document 181 for details.</p> 182 183 </div></div> 184 <div class="bottomlang"> 185 <p><span>Available Languages: </span><a href="../en/vhosts/ip-based.html" title="English"> en </a> | 186 <a href="../fr/vhosts/ip-based.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | 187 <a href="../ja/vhosts/ip-based.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | 188 <a href="../ko/vhosts/ip-based.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | 189 <a href="../tr/vhosts/ip-based.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> 190 </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 again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div> 191 <script type="text/javascript"><!--//--><![CDATA[//><!-- 192 var comments_shortname = 'httpd'; 193 var comments_identifier = 'http://httpd.apache.org/docs/2.2/vhosts/ip-based.html'; 194 (function(w, d) { 195 if (w.location.hostname.toLowerCase() == "httpd.apache.org") { 196 d.write('<div id="comments_thread"><\/div>'); 197 var s = d.createElement('script'); 198 s.type = 'text/javascript'; 199 s.async = true; 200 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; 201 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); 202 } 203 else { 204 d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); 205 } 206 })(window, document); 207 //--><!]]></script></div><div id="footer"> 208 <p class="apache">Copyright 2017 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> 209 <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[//><!-- 210 if (typeof(prettyPrint) !== 'undefined') { 211 prettyPrint(); 212 } 213 //--><!]]></script> 214 </body></html>