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.
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:
HTTP listeners associated with the virtual server named server:
The listener named http-listener-1 does not have security enabled.
The listener named http-listener-2 has security enabled
An HTTP listener named admin-listener, associated with the virtual server named __asadmin. This listener does not have security enabled.
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:
The remote create-http-listener command enables you to create an HTTP listener.
Ensure that the server is running.
Remote commands require a running server.
Create an HTTP listener by using the create-http-listener(1) command.
To apply your changes, restart Enterprise Server.
Stop Enterprise Server.
For instructions, see To Stop a Domain (or Server).
Start Enterprise Server.
For instructions, see To Start a Domain (or Server).
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. |
To see the full syntax and options of the command, type asadmin help create-http-listener at the command line.
The remote list-http-listeners command enables you to list the existing HTTP listeners.
Ensure that the server is running.
Remote commands require a running server.
List HTTP listeners by using the list-http-listeners(1) command.
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. |
To see the full syntax and options of the command, type asadmin list-http-listeners -help at the command line.
The remote delete-http-listener command enables you to delete an existing HTTP listener. This disables secure communications for the listener.
Ensure that the server is running.
Remote commands require a running server.
Obtain the exact name of the HTTP listener that you are deleting.
To list the existing HTTP listeners:
asadmin list-http-listeners |
If necessary, notify users that the HTTP listener is being deleted.
Delete an HTTP listener by using the delete-http-listener(1) command.
To apply your changes, restart Enterprise Server.
Stop Enterprise Server.
For instructions, see To Stop a Domain (or Server).
Start Enterprise Server.
For instructions, see To Start a Domain (or Server).
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. |
To see the full syntax and options of the command, type asadmin delete-http-listener -help at the command line.
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.
Ensure that the server is running.
Remote commands require a running server.
Configure an HTTP listener by using the create-ssl(1) command.
To apply your changes, restart Enterprise Server.
Stop Enterprise Server.
For instructions, see To Stop a Domain (or Server).
Start Enterprise Server.
For instructions, see To Start a Domain (or Server).
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. |
To see the full syntax and options of the command, type asadmin create-ssl --help at the command line.
The remote delete-ssl command enables you to delete the SSL element in the specified listener. This disables secure communications for the listener.
Ensure that the server is running.
Remote commands require a running server.
Delete SSL from an HTTP listener by using the delete-ssl(1) command.
To apply your changes, restart Enterprise Server.
Stop Enterprise Server.
For instructions, see To Stop a Domain (or Server).
Start Enterprise Server.
For instructions, see To Start a Domain (or Server).
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. |
To see the full syntax and options of the command, type asadmin delete-ssl --help at the command line.
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.
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:
A virtual server named server, which hosts all user-defined web modules.
For development, testing, and deployment of web services in a non-production environment, server is often the only virtual server required.
A virtual server named __asadmin, which hosts all administration-related web modules (specifically, the Administration Console). This server is restricted, which means that you cannot deploy web modules to this virtual server.
The following tasks are used to administer virtual servers:
The remote create-virtual-server command enables you to create the named virtual server.
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.
Ensure that the server is running.
Remote commands require a running server.
Create a virtual server by using the create-virtual-server(1) command.
To apply your changes, restart Enterprise Server.
Stop Enterprise Server.
For instructions, see To Stop a Domain (or Server).
Start Enterprise Server.
For instructions, see To Start a Domain (or 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. |
To see the full syntax and options of the command, type asadmin create-virutal-server --help at the command line.
The remote list-virtual-servers command enables you to list the existing virtual servers.
Ensure that the server is running.
Remote commands require a running server.
List virtual servers by using the list-virtual-servers(1) command.
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. |
To see the full syntax and options of the command, type asadmin list-virutal-servers --help at the command line.
The remote delete-virtual-server command enables you to delete an existing virtual server.
Ensure that the server is running.
Remote commands require a running server.
Obtain the exact name of the virtual server that you are deleting.
To list the existing virtual servers:
asadmin list-virtual-servers |
If necessary, notify users that the virtual server is being deleted.
Delete a virtual server by using the delete-virtual-server(1) command.
To apply your changes, restart Enterprise Server.
Stop Enterprise Server.
For instructions, see To Stop a Domain (or Server).
Start Enterprise Server.
For instructions, see To Start a Domain (or 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. |
To see the full syntax and options of the command, type asadmin delete-virutal-server --help at the command line.