Glassfish, Apache & AJP Connector
时间:2009-7-11 14:46 作者:fshell 分类: 无
If we run your Glassfish application server in your local network and you want your applications to serve your internet users, we may run our Apache server in front with reverse proxy. Apache can pass the requests to our Glassfish application server through its connector. Glassfish supports the standard http connector and the AJP connector. Personally, I like to to use the AJP connector because it maintains the original IP address from the client. To use the connectors, we need to load the needed Apache modules and configure Apache and Glassfish if necessary as follow:
* HTTP connector
modules: proxy, proxy_http ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass /app http://localhostname:8080/app ProxyPassReverse /app http://localhostname:8080/app
* AJP connector
modules: proxy, proxy_ajp ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass /app ajp://localhostname:8009/app ProxyPassReverse /app ajp://localhostname:8009/app
If we use AJP connector, we need to copy the following jar files to the lib sub directory of our Glassfish installation directory.
* commons-logging-api.jar * commons-modeler-2.0.jar * tomcat-ajp.jar
For AJP to work properly for Glassfish v2, these files must come from Tomcat 5.5.23. Files from other Tomcat versions may not work and may give
you an error: java.lang.NoSuchFieldError: USE_CUSTOM_STATUS_MSG_IN_HEADER.
To configure the Glassfish AJP connector:
From the console: $GLASSFISH_HOME/bin/asadmin create-jvm-options -Dcom.sun.enterprise.web.connector.enableJK=8009
From the console:
sudo ./asadmin create-jvm-options -Dcom.sun.enterprise.web.connector.enableJK.propertyFile = /path/glassfish/domains/domain1/config/glassfish-jk.properties
How come? Should i still copy the jar files across?