apache-httpd与resin的桥接mod_caucho,hmux

apache的httpd是一款流行的web服务端软件;resin是一款流行的java应用服务端软件,通常架设的服务是apache的httpd做web服务端,遇有jsp这样的请求转交给resin在后台执行、解析后再经由httpd转给用户,这样的流程满足了绝大多数的需求。尽管resin宣称是第一快的java应用服务端软件,甚至在处理静态文件的应答(html或者image等)也比httpd快,但业界似乎仍多钟情于httpd+resin的组合。

apache的httpd的配置桥接resin是通过常用的如下这样的方式进行的:

# mod_caucho Resin Configuration
LoadModule caucho_module modules/mod_caucho.so
ResinConfigServer localhost 6800
CauchoConfigCacheDirectory /tmp
CauchoStatus yes

这通常没错,也是resin推荐的配置,此时,如果在resin/conf/resin.properties 中打开如下:

# General log level (modify resin.xml for more granular log level adjustments)
log_level : finer
# Enable verbose browser error reporting
dev_mode : true

在resin的日志文件里会惊奇地发现,无论是请求jsp文件,还是html文件(静态),resin总是能收到请求处理信息,即便在 resin/conf所有所见之处都屏蔽了对html等静态文件的接管处理。日志如下:

[15-04-07 11:27:59.943] {server://127.0.0.1:6800-11} TcpSocketLink[id=server://127.0.0.1:6800-11,server://127.0.0.1:6800,KEEPALIVE_THREAD] keepalive disabled from KEEPALIVE_THREAD, reason=thread-keepalive timeout
[15-04-07 11:27:59.944] {server://127.0.0.1:6800-33} TcpSocketLink[id=33,app-0] starting connection TcpSocketLink[id=server://127.0.0.1:6800-33,server://127.0.0.1:6800,ACCEPT], total=28
[15-04-07 11:27:59.944] {server://127.0.0.1:6800-33} Hmux[app-0:33] start request
[15-04-07 11:27:59.944] {server://127.0.0.1:6800-33} Hmux[app-0:33] channel-r 1
[15-04-07 11:27:59.944] {server://127.0.0.1:6800-33} Hmux[app-0:33] P-r: dispatch protocol
[15-04-07 11:27:59.944] {server://127.0.0.1:6800-33} Hmux[app-0:33] etag: h-default
[15-04-07 11:27:59.944] {server://127.0.0.1:6800-33} Hmux[app-0:33] host: labs.people.com.cn
[15-04-07 11:27:59.944] {server://127.0.0.1:6800-33} Hmux[app-0:33] query:
[15-04-07 11:27:59.944] {server://127.0.0.1:6800-33} Hmux[app-0:33] host alias ‘labs.people.com.cn -> ‘Host[production/host/default]’ no change
[15-04-07 11:27:59.944] {server://127.0.0.1:6800-33} Hmux[app-0:33] n
[15-04-07 11:27:59.944] {server://127.0.0.1:6800-33} Hmux[app-0:33] Q: end of request
[15-04-07 11:27:59.944] {server://127.0.0.1:6800-33} Hmux[app-0:33] flush()
[15-04-07 11:27:59.944] {server://127.0.0.1:6800-33} TcpSocketLink[id=33,app-0] keepalive (thread)
[15-04-07 11:27:59.944] {server://127.0.0.1:6800-33} Hmux[app-0:33] start request
[15-04-07 11:27:59.944] {server://127.0.0.1:6800-33} Hmux[app-0:33] channel-r 1

也即,如果使用上述配置,而没有在apapche/conf/httpd.conf中做预审判断的话,请求总是会被发送到resin那里,可能被执行、解析,也可能没有。改变这种将html请求也发给resin的做法是在 apache/conf/httpd.conf中做明确的转发判断,mod_caucho做如下这样的设置:

LoadModule caucho_module modules/mod_caucho.so
CauchoHost localhost 6800
AddHandler caucho-request jsp
<FilesMatch \.jsp$>
SetHandler caucho-request
</FilesMatch>

重启apache之后,再次测试请求jsp会被顺利送达resin进行相应处理,而请教html则不会在无辜转动resin中周折。

或许在源码一层的分析更有确切的策略消息。

This entry was posted in 服务器运维, 编程技术, 计算机技术. Bookmark the permalink.

2 Responses to apache-httpd与resin的桥接mod_caucho,hmux

  1. Pingback: apache-httpd与resin的桥接mod_caucho,hmux | -wordpress-wadelau

  2. Pingback: libstdc++ conflicts itself, perl, yast, git | -UFQI-Blog

发表评论

电子邮件地址不会被公开。 必填项已用*标注