This document has the following sections:
To assign a virtual host you must first determine which situation applies to you.
NOTE: In order to properly use the virtual hosting feature of the the JavaServer, you must have already set up your network to recognize the host and domain names you want to define. If you have not previously done this configuration in your DNS host maps, setting virtual hosting in the JavaServer will not work.
NOTE: In some cases, your system can have multiple interface cards, each with a number of hosts, and all can be mapped to a single IP Address. But this is for advanced users and beyond the scope of this document.
When you set up virtual hosting, you register the additional hostnames and document roots with the JavaServer. Then, when a request addressed to your IP address comes in from across the net, the JavaServer looks at the header sent along with the request and uses it to serve the right HTML documents to fulfill the request.
For example, your machine's IP address is 127.150.89.77, and you have
previously mapped the names zebop
and muddy
to
your IP address in the DNS hosts maps. Then, in the
Basic Setup page you set up zebop
to
be your primary host, with the default document root
server_root/public_html
.
You then use the Virtual Hosts Setup page to register the additional (or
"virtual") host name and document root with the JavaServer. For example, you
register a second hostname as muddy,
with the document root
server_root/MuddyDocs/public_html
.
When an HTTP request comes in to your JavaServer, it actually comes in pointing at the IP address 127.150.89.77. However, the JavaServer knows to read the header that comes alone with the request and therefore fulfill the request by serving up the right documents.
For example, if someone on the net connects to http://zebop:8080
,
the JavaServer knows to serve up the documents in
server_root/public_html
. Similarly, if an HTTP request
comes in pointing at http://muddy:8080
, the JavaServer knows to
fulfill the request with the documents in
server_root/MuddyDocs/public_html
.
Both requests have the same IP address: the JavaServer knows how to distinguish
between them to treat each host as its own separate and "virtual" identity.
For example, you could set up DNS to map the host zebop
to
the domain www.mymusic.com
, and the host muddy
to the domain www.more_music.com
. Anyone on the net who
connects to http://www.mymusic.com
will be served the documents
in the directory set up for zebop
,
(server_root/public_html
), and anyone who connects to
http://www.more_music.com
will be served the documents in the
directory set up for muddy
(server_root/MuddyDocs/public_html
).
Once you have properly installed the cards needed to assign a second IP Address to your machine, setting up virtual hosts works exactly the same for each IP as described above. For more information, see Virtual Hosting with One IP Address.
Host
The host name as it would appear in the URL that is used to locate the page, should be
specified here, for example, zebop
or muddy
.
muddy
).
A relative pathname is entered without a starting slash (for example,
MuddyDocs/public_html
). Relative pathnames entered without the
starting slash (/) are always read "relative" to server_root.
So, MuddyDocs/public_html
without the starting slash
means server_root/MuddyDocs/public_html
.
An absolute pathname is entered with the starting slash (for example,
/home/erik/docs/public_html
). Just like a standard Unix
pathname, it is not resolved relative to server_root but
absolutely from the Unix "root," exactly as it is entered.