Chapter 5. Virtual Hosts

Table of Contents

5.1. Overview
5.2. Web Engine and Virtual Host
5.2.1. ServletContext Object and Virtual Hosts
5.3. Web Context Requests to Virtual Host
5.3.1. URL Matching Example
5.3.2. URL Matching Order
5.4. Configuring Virtual Hosts
5.4.1. Addition
5.4.2. Modification
5.4.3. Deletion

This chapter describes the basic concepts, rules, and configurations of virtual hosts.

Virtual hosts allow different web applications to be mapped with the same URL based on the Internet domain name. In other words, two or more domain names (for example, “www1.foo.com” and “www2.foo.com”) can exist on a single web engine and use different web contexts.

Note

From the perspective of web engines, web contexts and web applications are the same.

This section describes the purpose and rules of virtual hosts and how ServletContext objects are related to virtual hosts.

Purpose

Virtual hosts allows mapping of different web applications to the same URL based on the domain name mapped to the virtual host. This allows service providers to provide multiple web sites on a single web engine. This is similar to the function that provides a virtual host through the Host header of HTTP 1.1.

A virtual host is a group of web contexts that can be configured on a web engine. Refer to [Figure 1.1] for more information about where the virtual host is positioned as a web engine component.

The following diagram shows how virtual hosts are used depending on their purposes.


In the previous example, it appears that the same context path (/service) is being accessed through two different addresses. There is one server, but from the perspective of the clients, there appear to be two servers, "www.foo.com" and "www.bar.com".

The service provider can provide different services with the same "/service" address pattern. In the previous example, "www.foo.com" provides services in Korean and "www.bar.com" provides services in English.

Rules

The following rules apply when creating virtual hosts.

JEUS web engines have a default virtual host. When deploying a web context, if a virtual host is not set, the web context will be deployed to the default virtual host. The name of the default virtual host is 'DEFAULT_HOME'. This is a reserved word that cannot be used as another virtual host name.

This section describes how to map URLs to web contexts on a virtual host.

The following example shows the relationships between a web engine, virtual hosts, and web contexts.


The following describes the virtual hosts and web contexts that are mapped to URLs based on the previous figure,[Figure 5.2].

  • http://www.foo.com/ctx1/test.jsp

    Matching virtual hostA
    Matching web context namectx1
  • http://www.foo.com/ctx2/test.jsp

    Matching virtual hostA
    Matching web context namectx2
  • http://www.bar.com/ctx1/

    Matching virtual hostB
    Matching web context namectx1-1
  • http://www.bar2.com/ctx1/test.jsp

    Matching virtual hostC
    Matching web context nameNone (404 Not Found)
  • http://www.foo2.com/ctx2/

    Matching virtual hostC
    Matching web contextctx2-2

Warning

Web context name and context path have different concepts. In general, they have the same value, but they are different when the services are distinguished by virtual host as in the previous example.

Virtual hosts can be added, modified, and deleted in WebAdmin or the console tool.

Note

In the configuration examples of this section, "A", "B", and "C" are used as the host names for convenience. Use meaningful names in the production environment.

Virtual hosts can be added in WebAdmin or the console tool.

Using WebAdmin

The following shows how to add virtual hosts in WebAdmin.

Using the Console Tool

To add virtual hosts using the console tool, execute the add-virtual-host command as in the following. Refer toJEUS Reference Book. "4.2.8.7. add-virtual-host" for more information about the add-virtual-host command.

add-virtual-host [-cluster <cluster-name> | -server <server-name>]
                 <virtual-host-name>
                 -list <host-name-list>

Virtual hosts can be modified in WebAdmin or the console tool.

Using WebAdmin

The following shows how to add virtual hosts in WebAdmin.

Using the Console Tool

To modify virtual hosts using the console tool, execute the modify-virtual-host command.

For more information about the modify-virtual-host command, refer to JEUS Reference Book. "4.2.8.18. modify-virtual-host".

modify-virtual-host [-cluster <cluster-name> | -server <server-name>]
                    <virtual-host-name>
                    [-aluph <access-log-use-parent-handler(true/false)>
                    | -alf <access-log-format> 
                    | -aluse <use-access-log(true/false)> 
                    | -alext <access-log-excluded-extensions>]
                    [-hnrm <host-name> | -hnadd <host-name>]

WebAdmin or the console tool can be used to delete virtual hosts.

Using WebAdmin

The following shows how to delete a virtual host in WebAdmin.

Using the Console Tool

To delete virtual hosts using the console tool, execute the remove-virtual-host command as in the following.

For more information about the remove-virtual-host command, refer to JEUS Reference Book. "4.2.8.29. remove-virtual-host".

remove-virtual-host [-cluster <cluster-name> | -server <server-name>]
                    <virtual-host-name>