Sun Java System Web Server 6.1 SP12 Getting Started Guide

Chapter 2 Creating and Using Virtual Servers

A virtual server is a server that uses a unique combination of IP address, port number and host name to identify it. You might have several virtual servers, all of which use the same IP address and port number but are distinguished by their unique host names.

For instance, you might have one virtual server called hr.acme.com, and another called mis.acme.com, both of which reside on the same Web server instance, and listen for requests on the same port.

Using Virtual Server

Virtual servers have the following benefits:

Figure 2–1 Types of Virtual Server

Types of virtual server

As the above figure shows, there are two different types of virtual servers. Virtual servers that use a unique IP address and port combination are known as hardware virtual servers. Each web site configured on a hardware virtual server has a single IP address. This means that for each web site that you add, you need a new IP address. Because IP addresses are limited, this places a constraint on the number of virtual servers that you can configure.

The other type of virtual server is the software virtual server. Software virtual servers use an IP address and port combination, and also the contents of an HTTP Host Header (the requested host name) to distinguish one virtual server from another. This enables one machine (with one IP address) to support multiple web sites, each of which is uniquely identified on that machine by its HTTP Host Header. This eliminates the need for many IP addresses.

Sun Java System Web Server 6.1 supports both hardware (IP address-based) and software (HTTP Host Header-based) virtual servers.

When you install Sun Java System Web Server, a default virtual server is created automatically. You can however create other virtual servers and customize them according to your specific needs.

You might have several virtual servers running on a single machine and receive requests for information from hundreds of clients. How would the server know which virtual server should handle which request? Before the server can process a request, it must accept the request via a listen socket, then direct the request to the correct virtual server, based on the value of the IP address or the HTTP Host header. You could manage virtual servers separately or group them together with other “like” servers into a virtual server class.

Before you can create a virtual server, you need two things for it to work:

To create a listen socket and virtual server perform the following tasks:

For example, if you want to create a virtual server, hr.acme.com, you have to decide which listen socket it would use. You could use the default listen socket, ls1, that’s created automatically when you install the server or you might want to add a new one. See the below example to create a new listen socket .

ProcedureTo create a listen socket

  1. Go to the Preferences tab on the Server Manager.

  2. Click the Add Listen Socket link.

  3. Specify the ID of the listen socket and the port number it will listen on. Retain the default values listed for the other parameters on the page.

    This is shown in the Figure 2-2: Adding Listen Socket:

    Figure 2–2 Adding Listen Socket

    Adding listen socket

  4. Click OK and then Apply to save and apply your changes.

    Next, you need to decide which class you want your virtual server to belong to. Using classes, you can configure similar virtual servers at the same time, so you do not have to configure each one separately. You can use the default virtual server class, vsclass1, that is created automatically when you install the server or you can add a new class.

    See the below example to create a new virtual server class, vsclass2.

ProcedureTo create a virtual server class

  1. Access the Virtual Server Class tab in the Server Manager.

  2. Click the Add Class link.

  3. Specify the virtual server class name and the document root as an absolute path for the class.

    Figure 2–3 Adding a Class of Virtual Servers

    Adding a class of virtual servers

  4. Click OK and then Apply to save and apply your changes.

    Next, create a new virtual server that will use the new listen socket we created, ls2, and will be managed by the virtual server class, vsclass2 .

ProcedureTo create a virtual server

  1. Access the Virtual Server class tab in the Class Manager.

  2. Click the Add Virtual Server link.

  3. Specify the name of the virtual server, its connections, and the URL Hosts. In this example, we specify acme as the URL which clients will use to refer to the server.

    Figure 2–4 Creating a Virtual Server

    Creating a Virtual Server

  4. Click OK and then Apply to save and apply your changes.

    You can configure additional virtual server settings in two ways:

    • Using the Class Manager

    • Using the Virtual Server Manager

    On the Class Manager, the pages are organized by the kind of setting you want to change. Use the Class Manager if you want certain settings to apply to all the virtual servers in the class.

    On the Virtual Server Manager, the pages only pertain to one virtual server, so you can see and change all the settings for a specific server.

    Figure 2–5 Managing Virtual Servers

    Managing Virtual Servers

    The simplest way to publish content on the site is to put it in the docroot of the server. However, you do not have to copy everything that you want to publish on your site into the docroot directory. You can also put content into any directory that you have mapped as an additional document directory.

ProcedureTo create an additional document directory

For instance, you have a folder called /hr/publish containing pages you want to post to your site.

  1. Access the Virtual Server Class Manager, and click the Content Management tab.

  2. Click Additional Document Directories.

  3. Choose /hr as the URL prefix to map.

    Figure 2–6 Additional Document Directories

    Additional Document Directories

  4. Type /hr/publish as the filesystem directory to map those URLs to.

  5. Click OK.

    You can now type http://acme/hr in a browser window to access the content that you have mapped.

    All the virtual servers in a virtual server class, by default, have the same document root.

    For instance, you have two virtual servers hr.acme.com and mis.acme.com belonging to the same virtual server class. When you types http://hr.acme.com on a browser, you probably want them to be taken to a docroot that contains HR information, say /acme/hr. Similarly, when you type http://mis.acme.com on a browser, you want them to go to the MIS site, which has its docroot at say, /acme/mis. You need to configure the docroot for each virtual server individually to achieve this.

ProcedureTo change the document root of a virtual server

  1. Access the virtual server manager interface of the virtual server you want to configure, say acme.

  2. Click the Settings link.

    Figure 2–7 Virtual Server Document Root

    Virtual Server document root

  3. Edit the path that appears next to the Document Root field setting to point to a new document root.

  4. Click OK.

    You can now configure your virtual servers in many other ways to provide different services to different sets of end users, based on specific needs. The rest of this guide explains some of the more common tasks: