Tomcat behind an apache proxy error on path

夙愿已清 提交于 2021-01-27 13:47:59

问题


I'm trying to configure my apache 2.2 as a proxy to some applications on a server.

tomcat-jira : Installed with Jira´s installer; tomcat-dev : Just a container for another applications.

First, my httpd.conf is like this:

ProxyRequests Off
ProxyPreserveHost On

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

ProxyPass /jira http://dev.debian.local:8080/jira
ProxyPassReverse /jira http://dev.debian.local:8080/jira

ProxyPass /tomcat http://dev.debian.local:8088
ProxyPassReverse /tomcat http://dev.debian.local:8088

<Location /jira>
    Order allow,deny
    Allow from all
</Location>

<Location /tomcat>
   Order allow,deny
   Allow from all
</Location>

So when I type http://dev.debian.local/jira it works! But in tomcat-dev, http://dev.debian.local/tomcat, it shows the page, badbly, without styles, and when I click on manage-aps, it redirect to:

http://dev.debian.local/manager/html instead of http://dev.debian.local/tomcat/manager/html causing a 404 error.

On tomcat-jira it has a parameter to configure the application that is:

Its because is just one application, so it redirects properly. How can I do something like this on tomcat instance? Is there a context path for the tomcat root?


回答1:


Using ProxyPass to change the path of a web application, as you can see, usually ruins everything.

Instead, you should do either this:

ProxyPass /tomcat http://dev.debian.local:8088/tomcat
ProxyPassReverse /tomcat http://dev.debian.local:8088/tomcat

or this:

ProxyPass / http://dev.debian.local:8088
ProxyPassReverse / http://dev.debian.local:8088

If you take the second option, re-name your "tomcat" web application to "ROOT" (case-sensitive: use capitals, even on a cass-insensitive filesystem).



来源:https://stackoverflow.com/questions/30373067/tomcat-behind-an-apache-proxy-error-on-path

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