【问题标题】:How to forward only *.jsp or *.do requests to Tomcat using mod_proxy?如何使用 mod_proxy 仅将 *.jsp 或 *.do 请求转发到 Tomcat?
【发布时间】:2013-01-09 01:21:59
【问题描述】:

我正在使用 mod_proxy 模块来转发对我的一个域的所有请求,以由 Tomcat 提供服务。但是,我只想将以 *.jsp 或 *.do 或 *.something 结尾的请求转发给 Tomcat 并由 Apache 服务器提供休息(例如 *.html、*.php、*.png)。如何使用 mod_proxy 来实现?

以下是我当前使用的示例 httpd.conf 配置:

<VirtualHost *:80>
    DocumentRoot /usr/share/tomcat6/webapps/mywebapp
    ServerName example.com
    ServerAlias www.example.com
    ProxyRequests Off
    ProxyPreserveHost On

    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>

    ProxyPass         /  ajp://localhost:8009/
    ProxyPassReverse  /  ajp://localhost:8009/
</VirtualHost>

【问题讨论】:

  • OK 我终于找到了,答案是ProxyPassMatch

标签: apache tomcat mod-proxy


【解决方案1】:

我知道你已经找到了答案,但我为可能需要它的其他人写了这个答案:

<Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>

    #ProxyPass         /  ajp://localhost:8009/
    ProxyPassMatch ^/(.*\.do)$ ajp://localhost:8009/$1
    ProxyPassMatch ^/(.*\.jsp)$ ajp://localhost:8009/$1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-14
    • 2014-02-25
    • 1970-01-01
    • 2013-02-25
    • 2012-04-24
    • 2013-03-02
    • 2010-09-12
    • 2014-06-07
    相关资源
    最近更新 更多