Oracle GlassFish Server 3.0.1 Administration Guide

Administering Virtual Servers

A virtual server is a virtual web server that serves content targeted for a specific URL. Multiple virtual servers can serve content using the same or different host names, port numbers, or IP addresses. The HTTP service directs incoming web requests to different virtual servers based on the URL.

When you first install GlassFish Server, a default virtual server is created. You can assign a default virtual server to each new HTTP listener you create.

Web applications and Java EE applications containing web components (web modules) can be assigned to virtual servers during deployment. A web module can be assigned to more than one virtual server, and a virtual server can have more than one web module assigned to it. If you deploy a web application and don't specify any assigned virtual servers, the web application is assigned to all currently defined virtual servers. If you then create additional virtual servers and want to assign existing web applications to them, you must redeploy the web applications. For more information about deployment, see the Oracle GlassFish Server 3.0.1 Application Deployment Guide.

You can define virtual server properties using the asadmin set command. For example:


asadmin> set server-config.http-service.virtual-server.MyVS.property.sso-enabled="true"

Some virtual server properties can be set for a specific web application. For details, see sun-web-app in Oracle GlassFish Server 3.0.1 Application Deployment Guide.

The following topics are addressed here:

ProcedureTo Create a Virtual Server

By default, when GlassFish Server starts, the following virtual servers are started automatically:

In a production environment, additional virtual servers provide hosting facilities for users and customers so that each appears to have its own web server, even though there is only one physical server.

Use the create-virtual-server subcommand in remote mode to create the named virtual server.

Before You Begin

A virtual server must specify an existing HTTP listener. Because the virtual server cannot specify an HTTP listener that is already being used by another virtual server, create at least one HTTP listener before creating a new virtual server.

  1. Ensure that the server is running.

    Remote subcommands require a running server.

  2. Create a virtual server by using the create-virtual-server(1) subcommand.

    Information about properties for this subcommand is included in this help page.

  3. To apply your changes, restart GlassFish Server.

    See To Restart a Domain.


Example 16–16 Creating a Virtual Server

This example creates a virtual server named sampleServer on localhost.


asadmin> create-virtual-server sampleServer
Command create-virtual-server executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help create-virutal-server at the command line.

ProcedureTo List Virtual Servers

Use the list-virtual-servers subcommand in remote mode to list the existing virtual servers.

  1. Ensure that the server is running.

    Remote subcommands require a running server.

  2. List virtual servers by using the list-virtual-servers(1) subcommand.


Example 16–17 Listing Virtual Servers

This example lists the virtual servers for localhost.


asadmin> list-virtual-servers
sampleListener
admin-listener
http-listener-2
http-listener-1
Command list-http-listeners executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help list-virutal-servers at the command line.

ProcedureTo Update a Virtual Server

  1. List virtual servers by using the list-virtual-servers(1) subcommand.

  2. Modify the values for the specified virtual server by using the set(1) subcommand.

    The virtual server is identified by its dotted name.

ProcedureTo Delete a Virtual Server

Use the delete-virtual-server subcommand in remote mode to delete an existing virtual server.

  1. Ensure that the server is running.

    Remote subcommands require a running server.

  2. List virtual servers by using the list-virtual-servers(1) subcommand.

  3. If necessary, notify users that the virtual server is being deleted.

  4. Delete a virtual server by using the delete-virtual-server(1) subcommand.

  5. To apply your changes, restart GlassFish Server.

    See To Restart a Domain.


Example 16–18 Deleting a Virtual Server

This example deletes the virtual server named sampleServer from localhost.


asadmin> delete-virtual-server sampleServer
Command delete-virtual-server executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help delete-virutal-server at the command line.

To Assign a Default Web Module to a Virtual Server

A default web module can be assigned to the default virtual server and to each new virtual server. To access the default web module for a virtual server, point the browser to the URL for the virtual server, but do not supply a context root. For example:

http://myvserver:3184/

A virtual server with no default web module assigned serves HTML or JavaServer Pages (JSP) content from its document root, which is usually domain-dir/docroot. To access this HTML or JSP content, point your browser to the URL for the virtual server, do not supply a context root, but specify the target file.

For example:

http://myvserver:3184/hellothere.jsp

ProcedureTo Assign a Virtual Server to an Application or Module

You can assign a virtual server to a deployed application or web module.

Before You Begin

The application or module must already be deployed. For more information, see Oracle GlassFish Server 3.0.1 Application Deployment Guide.

  1. In the Administration Console, open the HTTP Service component under the relevant configuration.

  2. Open the Virtual Servers component under the HTTP Service component.

  3. Select the virtual server to which you want to assign a default web module.

  4. Select the application or web module from the Default Web Module drop-down list.

    For more information, see To Assign a Default Web Module to a Virtual Server.