2

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.

4
  • Still can't get this to work on a subfolder, when proxying root folder all works.
    – Indrek
    Dec 1, 2010 at 10:42
  • I gave up, was much cheaper to buy a domain for that test-server :)
    – Indrek
    Dec 6, 2010 at 19:24
  • Why would you buy a second domain rather than use a subdomain?
    – Corey S.
    Dec 7, 2010 at 13:28
  • Because I didn't have a domain name under which I would like to put that kind of stuff... :) I was using a free subdomain.
    – Indrek
    Dec 8, 2010 at 13:09

4 Answers 4

3

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

1
  • This seems to be the most informative answer, as none of the other suggestions seemed to fix my problem (or I'm doing it all wrong).
    – Indrek
    Dec 8, 2010 at 13:11
2

You might try this article, which explains the appropriate way to use ProxyPassReverse:

http://www.humboldt.co.uk/2009/02/the-mystery-of-proxypassreverse.html

1

Since you are outputting absolute URLS there are multiple common scenarios:

Use mod_proxy_html.

Or you might use RewriteEngine to rewrite URLS in / to /myapp/.

RewriteEngine On
RewriteCond %{REQUEST_URI} ! ^/myapp/
RewriteRule ^/(.*)$ /myapp/$1

This is from memory so, you might want to verify this yourself via the mod_rewrite Documentation. But I would recommend sticking with mod_proxy_html since rewriting the links being sent out to clients would be less complex than rewriting every request internally.

3
  • Could you explain about the rewriting rules a bit more? I'd like to write my.domain.com/subfolder to localhost:8080/someotherfolder
    – Indrek
    Dec 2, 2010 at 8:52
  • that seems completely unrelated to the base problem? I thought you were getting hits to the Reverseproxys directory root which causes the error?
    – pacey
    Dec 2, 2010 at 9:39
  • Sorry, I may have not described very well in my last comment. Yes, it is the reverse proxying that has problems I guess, the URLs are shown to my.domain.com/PATH not to my.domain.com/tomcat/PATH. How can I use Apache URL rewriting to rewrite the URLs generated by Tomcat?
    – Indrek
    Dec 2, 2010 at 13:38
0

In case you need to go back to mod_proxy:

<Location /tomcat>
    ProxyPass ajp://127.0.0.1:8009/tomcat
    ProxyPassReverse ajp://127.0.0.1:8009/tomcat
</Location>
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .