HydraExpress User Guide : PART II The HydraExpress Agent : Chapter 3 Overview of Agent Configuration : Configuring Apache as an External Web Server
Configuring Apache as an External Web Server
You may wish to use an external Web server with HydraExpress. You may use any Web server for this, but HydraExpress has some built-in support for using the Apache Web server in conjunction with the Apache Tomcat file mod_jk. This section describes using Apache with the AJP13 protocol. See the Apache Web server documentation for other advanced options such as using Apache to proxy HTTP requests.
Configuring the HydraExpress AJP 1.3 Connector
HydraExpress ships with a connector that accepts requests from an Apache Web server. This connector is configured in rwagent.xml located in your installdir\conf directory, with a default port of 8009. Here is a relevant excerpt from that file:
 
<rwsf:connector name="AJP 1.3"
class="rwsf_transport_ajp1346.createAjp13ConnectorImp"
handlerChain="http">
<rwsf:property name="accepter-threads" value="1"/> 1
<rwsf:property name="thread-pool-min" value="5"/> 2
<rwsf:property name="thread-pool-max" value="10"/> 3
<rwsf:property name="host" value="localhost"/> 4
<rwsf:property name="port" value="8009"/>
<rwsf:property name="request-backlog" value="5"/> 5
<rwsf:property name="request-buffersize" value="4096"/> 6
<rwsf:property name="request-timeout" value="30000"/> 7
</rwsf:connector>
//1 Specifies the number of threads that should be spawned listening for new connections. Defaults to 1.
//2 The minimum number of threads to be created in the thread pool. Defaults to 5.
//3 The maximum number of threads to be created in the thread pool, in this case 20. Defaults to 10.
//4 The host property defines servers from which messages will be accepted; in this case, localhost only.
//5 The number of pending connection requests allowed before the system starts refusing connections.
//6 Size of the buffer used to receive incoming messages.
//7 Timeout used when returning a request to the client, specified in milliseconds.
You may customize this configuration to complement your Apache Web server configuration.
Configuring the Apache Web Server
The Agent uses mod_jk, provided by the Apache Software Foundation, to communicate with an Apache Web server. This module reads the Apache worker.properties file to configure the connections that the Web server makes to the Agent. This section provides some information about the settings in the worker.properties file. For complete information, see the Apache documentation. Also, this section alludes to but does not describe how to set up load balancing in an Apache server. Again, see the Apache documentation for this information, or refer to the Rogue Wave Knowledge Base for a relevant article.
NOTE >> For convenience, HydraExpress ships with certified binaries of the mod_jk library for some platforms. You can find these binaries in <installdir>\3rdparty\jk-1.2. Each platform-specific subdirectory contains a readme file with version and compatibility information. These libraries are provided as-is and are based on the versions of the Apache Web server certified against the product. If you have a different version of Apache and need the compatible mod_jk library, you can obtain the source and some binary versions at http://tomcat.apache.org/download-connectors.cgi.
The worker.properties file configures workers. A worker represents the concept of a connection to a server. A worker often corresponds to an actual on-the-wire connection, but it may also be an intermediary between the Web server and other workers. For example, a load-balancing worker is a connector that balances requests among a number of other workers.
Each configuration line has the format property=value. For example, the line below sets the port number for a worker named container1 to port 8007:
 
worker.container1.port=8007
Setting the Worker Type
HydraExpress supports the following worker types:
An ajp13 worker communicates with the Agent over the AJP13 protocol. This is the recommended protocol for communicating with the Agent. “Configuring AJP13 Workers” describes ajp13 workers.
An lb worker load balances requests to other workers.
To set the type of a worker, use the syntax worker.name.type=<workertype>. For example, the line below declares the worker with the name container1 to be of type ajp13:
 
worker.container1.type=ajp13
Configuring AJP13 Workers
An ajp13 worker represents an AJP13 connection to the Agent. Each ajp13 worker has two required properties and two optional properties.
An ajp13 worker must be configured with the properties in Table 6 :
Table 6 – Required properties for an ajp13 worker 
Property
Description
host
Name of the server that runs the Agent.
port
Port number of the Agent. The default port for the AJP13 connector is 8009.
An ajp13 worker may be configured with the properties in Table 7 :
Table 7 – Optional properties for an ajp13 worker 
Property
Description
lbfactor
Assigned weight for load balancing
cachesize
Number of socket connections the Web server opens to the Agent. (If this property is not explicitly set, the server opens one connection.) Typically, this number should be equal to the number of acceptor threads specified for the connector associated with the port.
For example, the configuration lines below set an ajp13 worker named container1 to connect to port 8009 on the local machine:
 
worker.container1.host=localhost
worker.container1.port=8009
If the optional elements were set, they might look like this:
 
worker.container1.lbfactor=2
worker.container1.cachesize=10
For more advanced configurations, see the Apache Tomcat mod_jk documentation.