How do I connect my tomcat app to apache 2 so the

2019-08-27 04:02发布

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

3条回答
看我几分像从前
2楼-- · 2019-08-27 04:42

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
查看更多
We Are One
3楼-- · 2019-08-27 04:51

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.

查看更多
ら.Afraid
4楼-- · 2019-08-27 04:56

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.

查看更多
登录 后发表回答