【问题标题】:Mapping a URL between Apache and Tomcat, using mod_jk使用 mod_jk 在 Apache 和 Tomcat 之间映射 URL
【发布时间】:2012-04-30 13:03:09
【问题描述】:

我在Ubuntu Server 10.04.3 LTS 中使用Apache/2.2.14Apache Tomcat/6.0.29

这是我的jk.conf

JkWorkersFile /etc/libapache2-mod-jk/workers.properties
JkMount       /portal/* worker1
JkLogLevel    debug
JkMountCopy   All

这是我的workers.properties

ps=/

# Define 1 real worker named worker1
worker.list=worker1

# Set properties for worker named worker1 to use ajp13 protocol,
# and run on port 8009
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=1
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300

问题是每当我尝试通过 apache 访问 tomcat 时使用:http://my.host.com/portal,tomcat 会回复:

13:39:30,683 INFO  [PortalImpl:3829] Current URL /portal/ generates exception: null

如果我为工作人员使用不同的挂载点,问题就会消失:

JkMount       /portal/* worker1

但这迫使我在这里访问我的 tomcat 实例:http://my.host.com,这是我不想要的。

有什么方法可以用mod-jk重写网址吗?

【问题讨论】:

    标签: apache tomcat ubuntu url-rewriting mod-jk


    【解决方案1】:

    如果您只使用 mod_proxy 而不是 mod_ajp,则可以跳过所有配置...

    ProxyPass /foo http://localhost:8080/bar
    ProxyPassReverse /foo http://localhost:8080/bar
    

    这会将 /foo 代理到在端口 8080 上运行的本地服务器 URL /bar。

    【讨论】:

    • 如果我这样做 ProxyPass / http://localhost:8080ProxyPassReverse / http://localhost:8080 就可以了。我可以通过my.host.com 访问该网站。但如果我尝试:ProxyPass /portal http://localhost:8080ProxyPassReverse /portal http://localhost:8080 并访问my.host.com/portal,则只显示部分内容。找不到零件,因为它们缺少前缀 portal。我会说问题在于tomcat没有将前缀添加到动态内容中。但实际上这应该是apache的责任,使其对tomcat完全透明。有什么提示吗?
    猜你喜欢
    • 1970-01-01
    • 2013-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多