danb
danb

Reputation: 10379

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

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

Upvotes: 0

Views: 2900

Answers (3)

Matt Woodward
Matt Woodward

Reputation: 234

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.

Upvotes: 0

f4nt
f4nt

Reputation: 2671

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

Upvotes: 2

danb
danb

Reputation: 10379

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.

Upvotes: 0

Related Questions