You can front Enterprise Server with Apache HTTP Server by enabling the mod_jk protocol for one of Enterprise Server's network listeners, as described in this procedure. A typical use for mod_jk would be to have Apache HTTP Server handle requests for static resources, while having requests for dynamic resources, such as servlets and JavaServerTM Pages (JSPs), forwarded to, and handled by the Enterprise Server back-end instance.
When you use the jk-enabled attribute of the network listener, you do not need to copy any additional JAR files into the /lib directory. You can also create JK connectors under different virtual servers by using the network listener attribute jk-enabled.
Install Apache HTTP Server and mod_jk.
For information on installing Apache HTTP Server, see http://httpd.apache.org/docs/2.0/install.html.
For information on installing mod_jk, see http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html.
Configure the following files:
apache2/conf/httpd.conf, the main Apache configuration file
apache2/config/workers.properties or domain-dir/config/glassfish-jk.properties (to use non-default values of attributes described at http://tomcat.apache.org/tomcat-5.5-doc/config/ajp.html)
Start Apache HTTP Server (httpd).
Start Enterprise Server with at least one web application deployed.
In order for the mod_jk–enabled network listener to start listening for requests, the web container must be started. Normally, this is achieved by deploying a web application.
Create an HTTP listener by using the create-http-listener(1)subcommand.
asadmin> create-http-listener --listenerport 8009 --listeneraddress 0.0.0.0 --defaultvs server listener-name
where listener-name is the name of the new listener.
Enable mod_jk by using the set(1) subcommand.
Use the following format:
asadmin> set server-config.network-config.network-listeners. network-listener.listener-name.jk-enabled=true
where listener-name is the ID of the network listener for which mod_jk is being enabled.
If you are using the glassfish-jk.properties file and not referencing it in the httpd.conf file, point to the properties file by using the create-jvm-options(1) subcommand.
Use the following format:
asadmin> create-jvm-options -Dcom.sun.enterprise.web.connector.enableJK.propertyFile= domain-dir/config/glassfish-jk.properties
To apply your changes, restart Enterprise Server.
See To Restart a Domain.
This example shows an httpd.conf file that is set for mod_jk.
LoadModule jk_module /usr/lib/httpd/modules/mod_jk.so JkWorkersFile /etc/httpd/conf/worker.properties # Where to put jk logs JkLogFile /var/log/httpd/mod_jk.log # Set the jk log level [debug/error/info] JkLogLevel debug # Select the log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " # JkOptions indicate to send SSL KEY SIZE, JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories # JkRequestLogFormat set the request format JkRequestLogFormat "%w %V %T" # Send all jsp requests to GlassFish JkMount /*.jsp worker1 # Send all glassfish-test requests to GlassFish JkMount /glassfish-test/* worker1
This example shows a workers.properties or glassfish-jk.properties file that is set for mod_jk.
# Define 1 real worker using ajp13 worker.list=worker1 # Set properties for worker1 (ajp13) worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009
For more information on Apache, see http://httpd.apache.org/.
For more information on Apache Tomcat Connector, see http://tomcat.apache.org/connectors-doc/index.html.