如何安装与mod_jk的上下文中引用Tomcat应用程序? [英] How to mount context-referenced Tomcat application with mod_jk?

查看:208
本文介绍了如何安装与mod_jk的上下文中引用Tomcat应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Tomcat的运行速度 /富上下文中的WAR应用程序,这意味着它的网址是 http://example.com:8080/富。现在我想通过 mod_jk的以Apache HTTP服务器连接到Tomcat。这是我的 workers.properties 文件:

  worker.list = foo的
worker.foo.port = 8009
worker.foo.host =本地主机
worker.foo.type = AJP13
worker.foo.mount = /富/ *

工作得很好,但在这个网址: http://example.com/foo 。我想它是在 http://example.com 。我缺少什么?

PS。这是我的 MOD-jk.conf ,这是纳入的httpd.conf

 的LoadModule jk_module模块/ mod_jk.so
JkWorkersFile /usr/local/tomcat/conf/workers.properties
<虚拟主机*:80>
  服务器名foo.example.com
  JkMount / * foo的
< /虚拟主机>


解决方案

您基本上有两种选择:


  1. 修改您的Tomcat配置安装在根了战争。如何做到这一点取决于你究竟是如何部署应用程序。这是更简洁的方法,除非有一些preventing因素。

  2. 通过使用mod_rewrite重写URL开始/到/ foo的,在这一点上,它会通过你的JkMount传递到Tomcat处理关于Apache侧问题

对于第二个选项,您的Apache的配置会是这个样子:

 上的mod_rewrite#开启
RewriteEngine叙述在
#这是规则。使用正则表达式匹配任何URL以/开头,并重写
#/富/ remaining_part_of_URL。在[PT](直通)有必要进行改写
#请求都通过JkMount
重写规则^ /(。*)/富/ $ 1 [PT]#转发所有URL以foo开头到Tomcat
JkMount /富/ *工人

(这是没有实际测试过,希望它的工作原理是!)。您可能还需要使你的Apache的mod_rewrite(看看你的发行版,启用MODS的目录可能是答案)。

如果你需要更多地了解mod_rewrite的(相当强大的野兽),去这里:
<一href=\"http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule\">http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule

I have an WAR application running in Tomcat at /foo context, meaning that its URL is http://example.com:8080/foo. Now I'm trying to connect Apache HTTP Server to Tomcat through mod_jk. This is my workers.properties file:

worker.list=foo
worker.foo.port=8009
worker.foo.host=localhost
worker.foo.type=ajp13
worker.foo.mount=/foo/*

Works fine, but at this URL: http://example.com/foo. I would like it to be at http://example.com. What am I missing?

ps. This is my mod-jk.conf, which is included into httpd.conf:

LoadModule jk_module modules/mod_jk.so
JkWorkersFile /usr/local/tomcat/conf/workers.properties
<VirtualHost *:80>
  ServerName foo.example.com
  JkMount /* foo
</VirtualHost>

解决方案

You basically have two options:

  1. Modify your Tomcat configuration to mount the WAR at the root. How this is done depends on how exactly you're deploying your application. This is the cleaner approach unless there's some preventing factor.
  2. Handle the problem on the Apache side by using mod_rewrite to rewrite URLs starting with / to /foo, at which point it will be passed through your JkMount to Tomcat

For the second option, your Apache configuration would look something like this:

# Turn on mod_rewrite
RewriteEngine On
# This is the rule. Use regexp to match any URL beginning with /, and rewrite it to
# /foo/remaining_part_of_URL. The [PT] (pass-through) is necessary to make rewritten
# requests go through JkMount
RewriteRule ^/(.*) /foo/$1 [PT]

# Forward all URLs starting with foo to Tomcat
JkMount /foo/* worker

(this isn't actually tested, hope it works as is!). You may also need to enable mod_rewrite in your Apache (check out your distribution, a mods-enabled directory might be the answer).

And if you need to know more about mod_rewrite (quite a powerful beast), go here: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule

这篇关于如何安装与mod_jk的上下文中引用Tomcat应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆