Sun GlassFish Enterprise Server v3 Prelude Administration Guide

Chapter 8 Administering the HTTP Service

The HTTP service provides functionality for deploying web applications and for making deployed web applications accessible by HTTP clients. HTTP services are provided by two kinds of related objects: HTTP listeners and virtual servers. This chapter provides procedures for administering the HTTP service in the Sun GlassFishTM Enterprise Server v3 Prelude environment by using the asadmin command-line utility.

The following topics are addressed here:

Instructions for accomplishing these tasks by using the Administration Console are contained in the Administration Console online help.

Administering HTTP Listeners

An HTTP listener is a listen socket that has an Internet Protocol (IP) address, a port number, a server name, and a default virtual server. Each virtual server provides connections between the server and clients through one or more HTTP listeners. Each HTTP listener must have a unique combination of port number and IP address. For example, an HTTP listener can listen on all configured IP addresses on a given port for a host by specifying the IP address 0.0.0.0. Alternatively, the HTTP listener can specify a unique IP address for each listener while using the same port.

Because an HTTP listener is a combination of IP address and port number, you can have multiple HTTP listeners with the same IP address and different port numbers, or with different IP addresses and the same port number (if your host was configured to respond to these addresses). The host running the Enterprise Server typically has access to only one IP address. HTTP listeners typically use the 0.0.0.0 IP address and different port numbers, with each port number serving a different purpose. However, if the host does have access to more than one IP address, each address can serve a different purpose.

By default, when Enterprise Server starts, the following HTTP listeners are started automatically:

To access a web application deployed on the Enterprise Server, use the URL http://localhost:8080/ (or https://localhost:8181/ for a secure application), along with the context root specified for the web application.

To access the Administration Console, use the URL https://localhost:4848/ or http://localhost:4848/asadmin/ (console default context root).

The following table describes the Enterprise Server default ports for the listeners that use ports.

Table 8–1 Default Ports for Listeners

Listener 

Default Port  

Description 

Administrative server 

4848 

A domain’s administrative server is accessed by the Administration Console and the asadmin utility. For the Administration Console, specify the port number in the URL of the browser. When running an asadmin command remotely, specify the port number by using the --port option.

HTTP 

8080 

The web server listens for HTTP requests on a port. To access deployed web applications and services, clients connect to this port. 

HTTPS 

8181 

Web applications configured for secure communications listen on a separate port. 

The following tasks are used to administer HTTP listeners:

ProcedureTo Create an HTTP Listener

The remote create-http-listener command enables you to create an HTTP listener.

  1. Ensure that the server is running.

    Remote commands require a running server.

  2. Create an HTTP listener by using the create-http-listener(1) command.

  3. To apply your changes, restart Enterprise Server.

    1. Stop Enterprise Server.

      For instructions, see To Stop a Domain (or Server).

    2. Start Enterprise Server.

      For instructions, see To Start a Domain (or Server).


Example 8–1 Creating an HTTP Listener

The following example command creates an HTTP listener named sampleListener that uses a non-default number of acceptor threads. Security is not enabled at runtime.


asadmin create-http-listener --listeneraddress 0.0.0.0 
--listenerport 7272 --defaultvs server --servername host1.sun.com 
--acceptorthreads 100 --securityenabled=false 
--enabled=false sampleListener

Information similar to the following is displayed:


Command create-http-listener executed successfully.

See Also

To see the full syntax and options of the command, type asadmin help create-http-listener at the command line.

ProcedureTo List HTTP Listeners

The remote list-http-listeners command enables you to list the existing HTTP listeners.

  1. Ensure that the server is running.

    Remote commands require a running server.

  2. List HTTP listeners by using the list-http-listeners(1) command.


Example 8–2 Listing HTTP Listeners

The following example command lists the HTTP listeners on localhost:


asadmin list-http-listeners

Information similar to the following is displayed:


sampleListener
admin-listener
http-listener-2
http-listener-1
Command list-http-listeners executed successfully.

See Also

To see the full syntax and options of the command, type asadmin list-http-listeners -help at the command line.

ProcedureTo Delete an HTTP Listener

The remote delete-http-listener command enables you to delete an existing HTTP listener. This disables secure communications for the listener.

  1. Ensure that the server is running.

    Remote commands require a running server.

  2. Obtain the exact name of the HTTP listener that you are deleting.

    To list the existing HTTP listeners:


    asadmin list-http-listeners
    
  3. If necessary, notify users that the HTTP listener is being deleted.

  4. Delete an HTTP listener by using the delete-http-listener(1) command.

  5. To apply your changes, restart Enterprise Server.

    1. Stop Enterprise Server.

      For instructions, see To Stop a Domain (or Server).

    2. Start Enterprise Server.

      For instructions, see To Start a Domain (or Server).


Example 8–3 Deleting an HTTP Listener

The following example command deletes the HTTP listener named sampleListener from localhost:


delete-http-listener sampleListener

Information similar to the following is displayed:


Command delete-http-listener executed successfully.

See Also

To see the full syntax and options of the command, type asadmin delete-http-listener -help at the command line.

ProcedureTo Configure an HTTP Listener for SSL

The remote create-ssl command enables you to create and configure an SSL element in the specified listener. This enables secure communication for the listener.

  1. Ensure that the server is running.

    Remote commands require a running server.

  2. Configure an HTTP listener by using the create-ssl(1) command.

  3. To apply your changes, restart Enterprise Server.

    1. Stop Enterprise Server.

      For instructions, see To Stop a Domain (or Server).

    2. Start Enterprise Server.

      For instructions, see To Start a Domain (or Server).


Example 8–4 Configuring an HTTP Listener for SSL

The following example command enables the HTTP listener named http-listener-1 for SSL:


asadmin create-ssl --type http-listener --certname sampleCert http-listener-1

Information similar to the following is displayed:


Command create-ssl executed successfully.

See Also

To see the full syntax and options of the command, type asadmin create-ssl --help at the command line.

ProcedureTo Delete SSL From an HTTP Listener

The remote delete-ssl command enables you to delete the SSL element in the specified listener. This disables secure communications for the listener.

  1. Ensure that the server is running.

    Remote commands require a running server.

  2. Delete SSL from an HTTP listener by using the delete-ssl(1) command.

  3. To apply your changes, restart Enterprise Server.

    1. Stop Enterprise Server.

      For instructions, see To Stop a Domain (or Server).

    2. Start Enterprise Server.

      For instructions, see To Start a Domain (or Server).


Example 8–5 Deleting SSL From an HTTP Listener

The following example command disables SSL for the HTTP listener named http-listener-1:


asadmin delete-ssl --type http-listener http-listener-1

Information similar to the following is displayed:


Command delete-http-listener executed successfully.

See Also

To see the full syntax and options of the command, type asadmin delete-ssl --help at the command line.

Administering Virtual Servers

A virtual server, sometimes called a virtual host, is an object that allows the same physical server to host multiple Internet domain names. All virtual servers hosted on the same physical server share the IP address of that physical server. A virtual server associates a domain name for a server (such as www.aaa.com) with the particular server on which Enterprise Server is running. Each virtual server must be registered with the DNS server for your network.


Note –

Do not confuse an Internet domain with the administrative domain of Enterprise Server.


For example, assume that you want to host the following domains on your physical server: www.aaa.com, www.bbb.com, and www.ccc.com. Assume that these domains are respectively associated with web modules web1, web2, and web3. This means that the following URLs are handled by your physical server:

http://www.aaa.com:8080/web1
http://www.bbb.com:8080/web2
http://www.ccc.com:8080/web3

The first URL is mapped to virtual server www.aaa.com, the second URL is mapped to virtual server www.bbb.com, and the third is mapped to virtual server www.ccc.com. For this mapping to work, www.aaa.com, www.bbb.com, and www.ccc.com must all resolve to your physical server’s IP address and each virtual server must be registered with the DNS server for your network.

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

The following tasks are used to administer virtual servers:

ProcedureTo Create a Virtual Server

The remote create-virtual-server command enables you 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 commands require a running server.

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

  3. To apply your changes, restart Enterprise Server.

    1. Stop Enterprise Server.

      For instructions, see To Stop a Domain (or Server).

    2. Start Enterprise Server.

      For instructions, see To Start a Domain (or Server).


Example 8–6 Creating a Virtual Server

The following example command creates a virtual server named sampleServer for hosts pigeon and localhost:


asadmin create-virtual-server --hosts pigeon,localhost sampleServer

Information similar to the following is displayed:


Command create-virtual-server executed successfully.

See Also

To see the full syntax and options of the command, type asadmin create-virutal-server --help at the command line.

ProcedureTo List Virtual Servers

The remote list-virtual-servers command enables you to list the existing virtual servers.

  1. Ensure that the server is running.

    Remote commands require a running server.

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


Example 8–7 Listing Virtual Servers

The following example command lists the virtual servers for localhost:


asaadmin list-virtual-servers

Information similar to the following is displayed:


sampleListener
admin-listener
http-listener-2
http-listener-1

Command list-http-listeners executed successfully.

See Also

To see the full syntax and options of the command, type asadmin list-virutal-servers --help at the command line.

ProcedureTo Delete a Virtual Server

The remote delete-virtual-server command enables you to delete an existing virtual server.

  1. Ensure that the server is running.

    Remote commands require a running server.

  2. Obtain the exact name of the virtual server that you are deleting.

    To list the existing virtual servers:


    asadmin list-virtual-servers
    
  3. If necessary, notify users that the virtual server is being deleted.

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

  5. To apply your changes, restart Enterprise Server.

    1. Stop Enterprise Server.

      For instructions, see To Stop a Domain (or Server).

    2. Start Enterprise Server.

      For instructions, see To Start a Domain (or Server).


Example 8–8 Deleting a Virtual Server

The following example command deletes the virtual server named sampleServer from localhost:


asadmin delete-virtual-server sampleServer

Information similar to the following is displayed:


Command delete-virtual-server executed successfully.

See Also

To see the full syntax and options of the command, type asadmin delete-virutal-server --help at the command line.