GlassFish v3 与 Apace Http Server的简易搭配

Fronting GlassFish v3 with Apache httpd

http://weblogs.java.net/blog/jfarcand/archive/2008/08/fronting_glassf.html

 

GlassFish v2 supported Apache httpd for a while...but when we started GlassFish v3, we dropped such support to focus on things like modularity, performance, a monster called Grizzly, etc. Hence previous version of v3 couldn't be used with Apache via Tomcat's mod_jk....that's no longer the case. Better, we have simplified the way to do it. You no longer needs special jars file from Tomcat. Apache support is now fully included inside our distribution, which makes it quite simple to enable. Much simpler that what I've described here

 

GF v2支持AHS有段时间了...而当我们开始GF v3的开发后,放弃了这样的支持以专注于某些方面,像模块性,性能,以及变态的Grizzly引擎等等.因此v3前面的版本不便和Apache通过Tomcat的Mod_JK一起使用....还好这种情况没有延续太久.而且我们现在实现了这一功能并进行简化了配置.你不再需要从Tomcat的Home下拷贝特别的jar文件.对Apache的支持已经完全整合在我们的发行版里面,相关的配置非常简单.就像下面的描述.

 

Want to try it? Download GlassFish v3 (wait for tomorrow nightly as I enabled support today) and just edit:

想尝试吗,下载GF v3吧,编辑domain.xml像这样:

 

% vi ${glassfish.home}/domains/domain1/config/domain.xml 

and add under your http-listener:

<http-listener default-virtual-server="server" family="inet" 
security-enabled="false" enabled="true" server-name="" 
address="0.0.0.0" acceptor-threads="1" port="8009" id="jk-connector"
xpowered-by="true" blocking-enabled="false" >
      <property name"jkEnabled" value="[true|false]">

 

That's it. Notice the port number. That's the one you need to add to your /etc/apache2/worker.properties file.

Haaaa!Much simpler than for GlassFish v2! The implementation is new so feel free to post your comments on the [email protected] alias in case you want...more!

Using mod_jk

To set up mod_jk, follow these steps:

  1. Obtain and install Apache 2.0.x or 2.2.x HTTP Server (http://httpd.apache.org/).

  2. Configure the following files:

    Examples of these files are shown after these steps. If you use both worker.properties and glassfish-jk.properties files, the file referenced by httpd.conf, or referenced by httpd.conf first, takes precedence.

  3. Start httpd.

  4. Enable mod_jk using the following command:


    asadmin set server-config.http-service.http-listener.listener.property.jkEnabled=true

    For example:


    asadmin set server-config.http-service.http-listener.http-listener1.property.jkEnabled=true

    Or you can use the following deprecated command, provided for backward compatibility:


    asadmin create-jvm-options -Dcom.sun.enterprise.web.connector.enableJK=8009
  5. If you are using the glassfish-jk.properties file and not referencing it in httpd.conf, point to it using the following command:


    asadmin create-jvm-options 
    -Dcom.sun.enterprise.web.connector.enableJK.propertyFile=domain-dir/config/glassfish-jk.properties
  6. Restart the Enterprise Server.

Here is an example httpd.conf file:

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

Here is an example worker.properties or glassfish-jk.properties file:

# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost.localdomain
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300

你可能感兴趣的:(apache,jvm,tomcat,socket,Glassfish)