`
dinghy
  • 浏览: 33756 次
  • 性别: Icon_minigender_1
  • 来自: 京广之间
社区版块
存档分类
最新评论

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 users@glassfish.dev.java.net 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
评论
3 楼 jerryscott2009 2008-12-02  
  感谢回复,看来要等glassfish的下一个版本了,毕竟mod_proxy有这么多好的方式。
  现在有一个启动优化的问题,就是glassfish由于是应用服务器,因此默认启动了许多服务,如果我只需要WEB服务的支持,能否在启动过程中屏蔽掉对诸如MQ EJB等模块的支持呢,这些该如何配置呢。
2 楼 dinghy 2008-12-01  
v2应该还不支持ahs2.2...因为刚看到官方文章说v2.1中刚刚可以支持ahs2.2下的loadbalancer.
不过你可以仿效v3下的设置,在相应的http-listener下,设置 <property name"jkEnabled" value="[true|false]">,
have a try,~~~
1 楼 jerryscott2009 2008-11-28  
   您好,最近我也在学习glassfish,就apache2.2和glassfish整合的问题,想请教
1. 你这篇文章介绍的是glassfishV3的版本,对于glassfishV2的是不是一样

2. 现在apache2.2后均使用mod_proxy的配置,但我配置了很久却无法将缺省的请求(80)的转到glassfish下面的http listener下(我当时想得很简单,如果用mod_proxy的正向代理,那么只要在http.conf下面 将请求转发到我在glassfish配置下的http listener即可,结果搞了半天都没有反应)

3. 是不是现在glassfishV2对于mod_proxy的那种方式不支持啊,网络上的文章都好像没有很明显介绍,能否指点一二呢。

相关推荐

Global site tag (gtag.js) - Google Analytics