Sophie

Sophie

distrib > Mandriva > 2010.0 > x86_64 > by-pkgid > c27466c2a3fa3cf6008c3a485d00ce04 > files > 111

jetty5-manual-5.1.15-1.5.2mdv2010.0.noarch.rpm

SECTION: 300-HTTP
TITLE: virtual
QUESTION: Does Jetty support virtual hosts?
<P>
Many domain names can be mapped to a single TCP/IP address.  If
different content needs to be served for each different domain, then the virtual
hosts mechanism needs to be used.
<P>
A HttpContext can be registered against one or more virtual host names. Only
requests that have a matching host header or fully qualified URL will be
passed to that context.
<P>
The setVirtualHosts method can be used to set an array of virtual host names
on a Context. In the jetty.xml file, this can be
done with:
<UL><TT><PRE>
  &lt;Call name="addWebApplication"&gt;
    &lt;Arg&gt;/context&lt;/Arg&gt;
    &lt;Arg&gt;./webapps/myapp&lt;/Arg&gt;

    &lt;Set name="virtualHosts"&gt;
      &lt;Array type="java.lang.String"&gt;
        &lt;Item&gt;www.acme.com&lt;/Item&gt;
        &lt;Item&gt;acme.com&lt;/Item&gt;
        &lt;Item&gt;www.wileyc.com&lt;/Item&gt;
        &lt;Item&gt;184.34.51.125&lt;/Item&gt;
      &lt;/Array&gt;
    &lt;/Set&gt;
  &lt;/Call&gt;
</PRE></UL></TT>
<P>
A null virtual host name is the same as no virtual host names and means the
context is available to requests that do not first match other virtual host contexts. 
<P>
If you want different content to be served from different real IP addresses,
then you do not need virtual hosts. Rather you need multiple instances of
HttpServer, each with their own listeners and contexts.