How to forward only *.jsp or *.do requests to Tomcat using mod_proxy?

流过昼夜 提交于 2019-12-13 16:53:30

问题


I am using mod_proxy module to forward all requests for one of my domain to be served by Tomcat. However I want to forward only requests ending *.jsp or *.do or *.something to Tomcat and rest (e.g. *.html, *.php, *.png) to be served by Apache server. How to achieve that using mod_proxy?

Following is sample httpd.conf config that I am using currently:

<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>

回答1:


I know that you had found the answer but I write this answer for others that maybe need it:

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

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


来源:https://stackoverflow.com/questions/14515708/how-to-forward-only-jsp-or-do-requests-to-tomcat-using-mod-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!