blob: c284e0b87f4ebd6e3c0be7e4fb3e9c23ac58a1d2 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Configuring Virtual Hosts</title><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1"><meta name="keywords" content="jetty, servlet-api, cometd, http, spdy, eclipse, maven, java, software"><link rel="home" href="index.html" title="Jetty : The Definitive Reference"><link rel="up" href="configuring-contexts.html" title="Chapter&nbsp;5.&nbsp;Configuring Contexts"><link rel="prev" href="configuring-contexts.html" title="Chapter&nbsp;5.&nbsp;Configuring Contexts"><link rel="next" href="configuring-webapps.html" title="Configuring WebAppContexts"><link xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" rel="shortcut icon" href="images/favicon.ico"><script type="text/javascript" src="js/shCore.js"></script><script type="text/javascript" src="js/shBrushJava.js"></script><script type="text/javascript" src="js/shBrushXml.js"></script><script type="text/javascript" src="js/shBrushBash.js"></script><script type="text/javascript" src="js/shBrushJScript.js"></script><script type="text/javascript" src="js/shBrushSql.js"></script><script type="text/javascript" src="js/shBrushProperties.js"></script><script type="text/javascript" src="js/shBrushPlain.js"></script><link type="text/css" rel="stylesheet" href="css/shCore.css"><link type="text/css" rel="stylesheet" href="css/shThemeEclipse.css"><link type="text/css" rel="stylesheet" href="css/font-awesome.min.css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><tr><td style="width: 25%"><a href="http://www.eclipse.org/jetty"><img src="images/jetty-header-logo.png" alt="Jetty Logo"></a><br><span style="font-size: small">
Version: 9.0.6.v20130930</span></td><td style="width: 50%"><script type="text/javascript"> (function() {
var cx = '016459005284625897022:obd4lsai2ds';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script><gcse:search></gcse:search></td></tr></table><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Configuring Virtual Hosts</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="configuring-contexts.html"><i class="icon-chevron-left"></i> Previous</a>&nbsp;</td><th width="60%" align="center">Chapter&nbsp;5.&nbsp;Configuring Contexts<br><a accesskey="p" href="index.html"><i class="icon-home"></i> Home</a></th><td width="20%" align="right">&nbsp;<a accesskey="n" href="configuring-webapps.html">Next <i class="icon-chevron-right"></i></a></td></tr></table><hr></div><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="jetty-callout"><h5 class="callout"><a href="http://www.webtide.com/support.jsp">Contact the core Jetty developers at
<span class="website">www.webtide.com</span></a></h5><p>
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ...
scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery
</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="configuring-virtual-hosts"></a>Configuring Virtual Hosts</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="configuring-virtual-hosts.html#configuring-a-virtual-host">Virtual Host Names</a></span></dt></dl></div><p>A virtual host is an alternative name, registered in DNS, for an IP
address such that multiple domain names will resolve the the same IP of a
shared server instance. If the content to be served to the aliases names is
different, then a virtual host names need to be configured for each deployed
context to indicate which names a context will respond to. </p><p>Virtual hosts are set on a context by calling the <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/server/handler/ContextHandler.html#setVirtualHosts(java.lang.String[])" target="_top"><code class="code">setVirtualHosts</code></a>
or <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/server/handler/ContextHandler.html#addVirtualHosts(java.lang.String[])" target="_top"><code class="code">addVirtualHost</code></a>
method which can be done either</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Using a context XML file in the webapps directory (see the example
in <a class="link" href="http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/plain/tests/test-webapps/test-jetty-webapp/src/main/config/webapps/test.xml" target="_top">test.xml</a>
in the jetty distribution).</p></li><li class="listitem"><p>Using a <code class="filename">WEB-INF/jetty-web.xml</code> file
(deprecated).</p></li><li class="listitem"><p>Creating a custom deployer with a binding to configure virtual
hosts for all contexts found in the same webapps directory.</p></li><li class="listitem"><p>Calling the API directly on an embedded usage.</p></li></ul></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="configuring-a-virtual-host"></a>Virtual Host Names</h3></div></div></div><p>Jetty supports the following styles of virtual host name:</p><div class="variablelist"><dl><dt><span class="term">www.hostname.com</span></dt><dd><p>A fully qualified host name. It is important to list all
variants as a site may receive traffic from both www.hostname.com
and just hostname.com</p></dd><dt><span class="term">*.hostname.com</span></dt><dd><p>A wildcard qualified host which will match only one level of
arbitrary names. *.foo.com will match www.foo.com and m.foo.com, but
not www.other.foo.com</p></dd><dt><span class="term">10.0.0.2</span></dt><dd><p>An IP address may be given as a virtual host name to indicate
that a context should handle requests received on that server port
that do not have a host name specified (HTTP/0.9 or HTTP/1.0)</p></dd><dt><span class="term">@ConnectorName</span></dt><dd><p>A connector name, which is not strictly a virtual host, but
instead will only match request that are received on connectors that
have a matching name set with <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/server/AbstractConnector.html#setName(java.lang.String)" target="_top">Connector.setName(String)</a>.</p></dd><dt><span class="term">www.&#8730;integral.com</span></dt><dd><p>Non ascii and <a class="link" href="http://en.wikipedia.org/wiki/Internationalized_domain_name" target="_top">IDN</a>
domain names can be set as virtual host using <a class="link" href="http://en.wikipedia.org/wiki/Punycode" target="_top">Puny Code</a>
equivalents that may be obtained from a <a class="link" href="http://network-tools.com/idn-convert.asp" target="_top">Punycode/IDN
converters</a>. For example if the non ascii domain name
<code class="literal">www.&#8730;integral.com</code> is given to a browser, then it
will make a request that uses the domain name
<code class="literal">www.xn--integral-7g7d.com</code>, which is the name that
should be added as the virtual host name.</p></dd></dl></div></div></div><script type="text/javascript">
SyntaxHighlighter.all()
</script><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="configuring-contexts.html"><i class="icon-chevron-left"></i> Previous</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="configuring-contexts.html"><i class="icon-chevron-up"></i> Top</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="configuring-webapps.html">Next <i class="icon-chevron-right"></i></a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;5.&nbsp;Configuring Contexts&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html"><i class="icon-home"></i> Home</a></td><td width="40%" align="right" valign="top">&nbsp;Configuring WebAppContexts</td></tr></table></div><p xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><div class="jetty-callout">
See an error or something missing?
<span class="callout"><a href="http://github.com/jetty-project/jetty-documentation">Contribute to this documentation at
<span class="website"><i class="icon-github"></i> Github!</span></a></span><span style="float: right"><i>(Generated: 2013-10-30T13:20:20-05:00)</i></span></div></p><script xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1149868-7']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script></body></html>