Commit 4a2fca4d authored by Lars Eilebrecht's avatar Lars Eilebrecht
Browse files

Some updates/modifications (based on the patch from the PR).

PR: 3549
Submitted by: Joshua Slive <slive+apachebugs@finance.commerce.ubc.ca>


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@82506 13f79535-47bb-0310-9956-ffa450edef68
parent 5a6501cf
Loading
Loading
Loading
Loading
+30 −15
Original line number Diff line number Diff line
@@ -40,34 +40,49 @@ solution is addressed below.</P>
<H2>Using non-IP Virtual Hosts</H2>

<P>Using the new virtual hosts is quite easy, and superficially looks
like the old method. You simply add to one of the Apache configuration
files (most likely <CODE>httpd.conf</CODE> or <CODE>srm.conf</CODE>)
code similar to the following:</P>
like the old method. The notable difference between IP-based and
name-based virtual host configuration is the
<A HREF="../mod/core.html#namevirtualhost"><CODE>NameVirtualHost</CODE></A>
directive which specifies an IP address that should be used as a
target for name-based virtual hosts.</P>

<P>For example, suppose that both <SAMP>www.domain.tld</SAMP> and
<SAMP>www.otherdomain.tld</SAMP> point at the IP address
<SAMP>111.22.33.44</SAMP>.  Then you simply add to one of the Apache
configuration files (most likely <CODE>httpd.conf</CODE> or
<CODE>srm.conf</CODE>) code similar to the following:</P>



<PRE>
    NameVirtualHost 111.22.33.44

    &lt;VirtualHost 111.22.33.44&gt;
    ServerName www.domain.tld
    DocumentRoot /web/domain
    DocumentRoot /www/domain
    &lt;/VirtualHost&gt;
</PRE>

<P>The notable difference between IP-based and name-based virtual host
configuration is the
<A HREF="../mod/core.html#namevirtualhost"><CODE>NameVirtualHost</CODE></A>
directive which specifies an IP address that should be used as a target for
name-based virtual hosts.
    &lt;VirtualHost 111.22.33.44&gt;
    ServerName www.otherdomain.tld
    DocumentRoot /www/otherdomain
    &lt;/VirtualHost&gt;
</PRE>

<P>Of course, any additional directives can (and should) be placed
into the <CODE>&lt;VirtualHost&gt;</CODE> section. To make this work,
all that is needed is to make sure that the name
<SAMP>www.domain.tld</SAMP> points to the IP address
<SAMP>111.22.33.44</SAMP></P>
all that is needed is to make sure that the names
<SAMP>www.domain.tld</SAMP> and <SAMP>www.otherdomain.tld</SAMP>
are pointing to the IP address <SAMP>111.22.33.44</SAMP></P>

<P>Note: When you specify an IP address in a <CODE>NameVirtualHost</CODE>
directive then requests to that IP address will only ever be served
by matching &lt;VirtualHost&gt;s.  The "main server" will <STRONG>never</STRONG>
be served from the specified IP address.
by matching &lt;VirtualHost&gt;s.  The "main server" will
<STRONG>never</STRONG> be served from the specified IP address.
If you start to use virtual hosts you should stop to use the "main server"
as an independent server and rather use it as a place for
configuration directives that are common for all your virtual hosts.
In other words, you should add a &lt;VirtualHost&gt; section for
<EM>every</EM> server (hostname) you want to maintain on your server.

<P>Additionally, many servers may wish to be accessible by more than
one name. For example, the example server might want to be accessible
+30 −15
Original line number Diff line number Diff line
@@ -40,34 +40,49 @@ solution is addressed below.</P>
<H2>Using non-IP Virtual Hosts</H2>

<P>Using the new virtual hosts is quite easy, and superficially looks
like the old method. You simply add to one of the Apache configuration
files (most likely <CODE>httpd.conf</CODE> or <CODE>srm.conf</CODE>)
code similar to the following:</P>
like the old method. The notable difference between IP-based and
name-based virtual host configuration is the
<A HREF="../mod/core.html#namevirtualhost"><CODE>NameVirtualHost</CODE></A>
directive which specifies an IP address that should be used as a
target for name-based virtual hosts.</P>

<P>For example, suppose that both <SAMP>www.domain.tld</SAMP> and
<SAMP>www.otherdomain.tld</SAMP> point at the IP address
<SAMP>111.22.33.44</SAMP>.  Then you simply add to one of the Apache
configuration files (most likely <CODE>httpd.conf</CODE> or
<CODE>srm.conf</CODE>) code similar to the following:</P>



<PRE>
    NameVirtualHost 111.22.33.44

    &lt;VirtualHost 111.22.33.44&gt;
    ServerName www.domain.tld
    DocumentRoot /web/domain
    DocumentRoot /www/domain
    &lt;/VirtualHost&gt;
</PRE>

<P>The notable difference between IP-based and name-based virtual host
configuration is the
<A HREF="../mod/core.html#namevirtualhost"><CODE>NameVirtualHost</CODE></A>
directive which specifies an IP address that should be used as a target for
name-based virtual hosts.
    &lt;VirtualHost 111.22.33.44&gt;
    ServerName www.otherdomain.tld
    DocumentRoot /www/otherdomain
    &lt;/VirtualHost&gt;
</PRE>

<P>Of course, any additional directives can (and should) be placed
into the <CODE>&lt;VirtualHost&gt;</CODE> section. To make this work,
all that is needed is to make sure that the name
<SAMP>www.domain.tld</SAMP> points to the IP address
<SAMP>111.22.33.44</SAMP></P>
all that is needed is to make sure that the names
<SAMP>www.domain.tld</SAMP> and <SAMP>www.otherdomain.tld</SAMP>
are pointing to the IP address <SAMP>111.22.33.44</SAMP></P>

<P>Note: When you specify an IP address in a <CODE>NameVirtualHost</CODE>
directive then requests to that IP address will only ever be served
by matching &lt;VirtualHost&gt;s.  The "main server" will <STRONG>never</STRONG>
be served from the specified IP address.
by matching &lt;VirtualHost&gt;s.  The "main server" will
<STRONG>never</STRONG> be served from the specified IP address.
If you start to use virtual hosts you should stop to use the "main server"
as an independent server and rather use it as a place for
configuration directives that are common for all your virtual hosts.
In other words, you should add a &lt;VirtualHost&gt; section for
<EM>every</EM> server (hostname) you want to maintain on your server.

<P>Additionally, many servers may wish to be accessible by more than
one name. For example, the example server might want to be accessible