Key

Using Virtual Hosts

A virtual host is an alternative name, registered in DNS, for an IP address. A single IP address may have many such alternative names.

Multi-homed hosts, that is machines with more than one network interface, may have a different name for each IP address. This is also refered to as "virtual hosting".

Essentially, "virtual hosting" concerns the resolution of a DNS registered name to an IP address - many names may resolve to the same IP address, and 1 or more IP addresses may reside on the same physical machine.

Jetty users often want to configure their web applications taking into account these different virtual hosts. Frequently, a machine with a single IP address will have different DNS resolvable names associated with it, and a webapp deployed on it must be reachable from all of the alternative names.

Other possibilities are to serve different web applications from different virtual hosts.

Let's examine these possibilities.

Configuration of virtual hosts

When configuring a web application, you can supply a list of IP addresses and names at which the web application will be reachable. Suppose we have a machine with these IP addresses and DNS resolvable names:

333.444.555.666

127.0.0.1

www.blah.com

www.blah.net

www.blah.org

Suppose we have a webapp, xxx.war that we want to be served from all of the above names and addresses. Then we would configure the webapp like so:

Configuring different webapps for different virtual hosts, but at the same context path

In our example above, we have made webapp zzz.war avilable not only at a certain set of virtual hosts, but also at the context path /zzz, whilst our other webapp is available at both a different set of virtual hosts, and at a different context path. What happens if we want them at the same context path, but still at different sets of virtual hosts?

Very simply, we just supply the same context path for each webapp, leaving the disjoint set of virtual host definitions as before:

Configuring virtual hosts with non-ascii characters

International domain names are names containing non-ascii characters. For example "http://www.bücher.com". The DNS internally remains based on ascii, so these kinds of names are translated via an encoding called punycode into an ascii representation. Modern browsers will detect these non-ascii characters in URLs and automatically apply the punycode encoding. For example, typing this url into a browser:

No Format

http://www.åäö.com:8080/test/

is translated to the following url:

No Format

http://www.xn--4cab6c.com:8080/test/

For using internationalized domain names with jetty virtual hosts, you need to supply the punycoded form of the name in your context xml file (and of course you will need to supply it to your DNS setup).

Here's an example. Say I'm running a webapp on port 8080 at context /test, and I want to configure a virtual host for "www.åäö.com". I configure its ascii equivalent in the context xml file for the context:

You'll notice that the link already has the punycode transformed domain name in it.

Contact the core Jetty developers at
www.webtide.com
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