Tomcat – Absolute urls not working with Apache2 AJP proxy Tomcat

ajpapache-2.2mod-proxytomcaturl

I don't seem to get how to configure ReverseProxy correctly. The URLs returned are all for the root directory "/", not "/tomcat" and only the main "default" tomcat page is displayed. I use Apache2 as a frontend for Tomcat with the following Proxy rules:

ProxyPass /tomcat ajp://127.0.0.1:8009/
ProxyPassReverse /tomcat ajp://127.0.0.1:8009/

I've also tried using the ProxyName in Tomcat's AJP connector setting. Using mod_rewrite to proxy the AJP request also gave the same result.

Apache error.log gives the following line (trying to load the images from its own root):

File does not exist: /var/www/asf-logo-wide.gif, referer:

EDIT: AJP works through mod_jk, but still getting the same problem with HTTP when using subfolders.

Best Answer

The problem is that your tomcat server is embedding links in the HTML with the path that it knows. Not the path to your proxy server. (Garnered this from your *.gif log entry)

ProxyPassReverse does not modify links in HTML. It only modifies the HTTP headers.

In order to get this to work, you need to configure tomcat with the appropriate location and path in the app's context. Likely, you'll need to rename the webapp.war file to ROOT.war and change any context config to "/".