How do I connect my tomcat app to apache 2 so the paths aren't lame?

倖福魔咒の 提交于 2019-12-11 17:20:53

问题


I've got a tomcat instance with several apps running on it... I want the root of my new domain to go to one of these apps (context path of blah).. so I have the following set up:

<Location />
    ProxyPass ajp://localhost:8025/blah
    ProxyPassReverse ajp://localhost:8025/blah
</Location>

it kinda works... going to mydomain.com/index.jsp works except the app still thinks it needs to add the /blah/ to everything like css and js.. is there something I can do without deploying the app to ROOT or changing the tomcat server config? I'd like to keep all this kind of thing on the apache side, if it's possible.

I'm thinking I may not be understanding the proxypassreverse directive..


回答1:


If you're wanting to server the app the /, Tomcat expects the app to be mounted at /, and have the name of ROOT. At least that's how I've always handled the situation personally. Even if you just symlink the app into ROOT, that should mitigate your problems. If you have an app placed in ${tomcat_home}/webapps/newapp, then Tomcat deploys it with a context of /newapp. At least, that's been the case in my history. Also, not sure if it matters but I've always used:

ProxyPass / ajp://localhost:8025/blah
ProxyPassReverse / ajp://localhost:8025/blah



回答2:


it looks like this is kind of a pain in the rear.

apache is literally rewriting pages as it serves them...

I think I'll go a different route.




回答3:


If you configure hosts on the Tomcat side as well then you can proxy to them and eliminate the context path for non-root webapps--in Tomcat server.xml:

<Host name="myhost">
  <Context path="" docBase="/path/to/files" />
</Host>

And on the Apache side:

<VirtualHost *:80>
  ServerName myhost
  ProxyPass / ajp://myhost:8009/
  ProxyPassReverse / ajp://myhost:8009/
</VirtualHost>

Hope that helps.



来源:https://stackoverflow.com/questions/230644/how-do-i-connect-my-tomcat-app-to-apache-2-so-the-paths-arent-lame

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