Virtual Servers with Glassfish and/or Apache
One of the reasons for which i would use Glassfish instead of Tomcat would be the possibility of remove Apache and achieve that my applications run completely on the platform Java. Nowadays all my applications use Apache for the its yield serving static content and for the configuration of the VirtualHost for each application. With Grizzly it seems that the perfromance of the HTTP/S service of Glassfish it's not going to be a problem, let's see if its support of Virtual Hosts is enought.
We already saw in the last post that across the console of administration we could configure the HTTP service. This configuration is based on three sections:
- The HTTP Service where we can form:
- The system logs of access to our applications (rotation and information that log register)
- Configuration HTTP RequestProcessing
- Management of the "keep-alive" connections (configuration of timeouts, and limit the number of connections)
- Configuration of the HTTP pool connection that wait for requests
- Definition of the HTTP head values that the server will response.
- Configuration of the static content cache to improve the performance
- HTTP Listeners are sockets (IP+Port) that are listening HTTP requests. In addition a listener can be associated with a VirtualServer / VirtualHost by default and with several names of machine. All the listeners use the HTTP Service configuration of Glassfish.
- Finally Virtual Servers (I like more the name of VirtualHost) they are the associations between a domain name and HTTP listeners. We could set an application as the default for one Virtual Server (the application is mounted as ROOT) but the meaning of Virtual Server is the relationship between one domain and one listener. It is important to emphasize that after changing the configuration of a Virtual Server it is not necessary to begin Glassfish again.
The truth is that basic configurations can be realized, I would say that it is at the same level of the Tomcat but with a simpler administration, but I miss some things that I usually use in Apache like redirections. To settle this in glassfish we can use URLRewriteFilter, which is great.
In any case, if the functionalities of Glassfish as Web Server do not seem enought or if you need Apache for other reasons, Glassfish supports the AJP protocol, so you can use Apache with mod_jk in front of Glassfish.
We must follow this steps
1.-Sdd a JVM property with the Web administration,
or from the console
$GLASSFISH_HOME/bin/asadmin create-jvm-options
-Dcom.sun.enterprise.web.connector.enableJK=8009
2.-Copy from Tomcat 5.5.x to %GLASSFISH %/lib the JAR files:
- %TOMCAT %/server/lib/tomcat-ajp.jar
- %TOMCAT %/server/lib/commons-modeler2.0.jar
3.-Copy commons-logging.jar to %GLASSFISH %/lib
4.-Optionally, to configure the AJP connector, set a configuration property file as another JVM Options:
$GLASSFISH_HOME/bin/asadmin create-jvm-options
-Dcom.sun.enterprise.web.connector.enableJK.propertyFile =
/path/glassfish/domains/domain1/config/glassfish-jk.properties
I was waiting for more options on Glassfish Web Server. They are working on it and v2 has introduced the support of virtual directories, but Apache keeps on giving more versatility. We will see if Grizzly, now independent from Glassfish, has something to say in the near future








