Note: Java Web Server uses the term "virtual hosting" in a slightly different way than other web servers with which you may be familiar. In Java Web Server, virtual hosting only affects document roots and is implemented using the HTTP/1.1. HOST header.
This document has the following sections:
When you set up virtual hosting, you register the additional hostnames and
document roots with the Java Web Server. Then, when a request addressed to your
IP address comes in from across the net, the Java Web Server looks at the
Host:
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
Network Setup page you set up zebop
to
be your primary host, with the default document root
server_root/public_html
(as shown in
Site Setup).
You then use the Virtual Hosts Setup page to register the additional (or
"virtual") host name and document root with the Java Web Server. 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 Java Web Server, it actually
points at the IP address 127.150.89.77. However, the Java Web Server knows to
read the Host:
header that comes along 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 Java Web Server knows to serve up the documents in
server_root/public_html
. Similarly, if an HTTP request
comes in pointing at http://muddy:8080
, the Java Web Server knows
to fulfill the request with the documents in
server_root/MuddyDocs/public_html
.
Both requests have the same IP address: the Java Web Server knows how to
distinguish between them to treat each host as its own separate and "virtual"
identity.
Note: This feature works only with browsers that send the
Host:
header, some older browsers may not.
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
).
Settings
The Virtual Hosts page has the following fields:
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
.
Document Root
Note: You cannot setup individual cgi-bin directories for
virtual hosts. All CGI scripts must be run from the Java Web Server
cgi-bin directory, server_root/
A relative pathname is entered without a starting slash (for example,
An absolute pathname is entered with the starting slash (for example,
The primary document directory (for example,
server_root/MuddyDocs/public_html
) that
contains the documents you want to serve for this host.
cgi-bin
.
Procedures
To Add a New Virtual Host:
Note: In the Document Root field, you can enter either a "relative"
pathname, or an absolute pathname.
muddy
).
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
.
/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.
To Modify a Virtual Host Entry:
To Remove a Virtual Host Entry:
Buttons
To make changes to the Virtual Hosts page and have those settings
take affect, use the five buttons at the bottom of the screen. These
are:
Top java-server-feedback@java.sun.com |
Copyright © 1997
Sun Microsystems, Inc. All Rights Reserved. |