httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bocalinda <>
Subject [users@httpd] Rewrite relative image paths in a reversed proxy setup
Date Mon, 17 Nov 2008 12:38:21 GMT
Hi all.

I have an Apache server that takes care of load balancing four Tomcat
servers, using mod_proxy.
The four Tomcat servers are setup in two clusters:

cluster1: 2 Tomcats 5.5.7
cluster2: 2 Tomcats 5.5.27

Now, I have depending on the application that is being requested, the
request should be send to cluster1 or cluster2.
I have this setup working using the <Location> tag.

<Proxy balancer://mycluster1>
        BalancerMember ajp:// route=vdebian1
        BalancerMember ajp:// route=vdebian2

<Proxy balancer://mycluster2>
        BalancerMember ajp:// route=vdebian3
        BalancerMember ajp:// route=vdebian4

<Location /SEDO>
       ProxyPass balancer://mycluster1 stickysession=JSESSIONID
       ProxyPassReverse /

<Location /SEDO-NEW>
       ProxyPass balancer://mycluster2 stickysession=JSESSIONID
       ProxyPassReverse /

This works perfectly as I expected. However, the problem I have is that some
images or links on my webapp are specified relatively.
For example <img href="image.gif">, which results in errors because the
image cannot be found on the root of my server, which is logical.

So, I thought I'd use the following:

<LocationMatch ^(.*\.gif)$>
        ProxyPassMatch balancer://mycluster1/$1

However, the problem is that I do not know to which application the image
belongs, thus I don't know either to which cluster I should proxy the
So I thought using mod_proxy_html to rewrite the URLs in the HTML files:

<Location /SEDO>
       ProxyPass balancer://mycluster1 stickysession=JSESSIONID
       ProxyPassReverse /
       SetOutputFilter proxy-html
       ProxyHTMLURLMap (.*\.gif)$1 Rie

This works, however, what I do not like is that I map the URLs to a
hardcoded server. What if the Tomcat instance is down? Then my images won't
be loaded.
As far as I tried, it is also impossible to specify a cluster path as URL.

Thus, my question folks, how can I solve this? I've been thinking about
using Vhosts, but I don't know if that would be the right solution. Maybe
there is something easier, such as altering a HTTP reponse header in order
to know which webapp requested the image.

Any help will be kindly appreciated.

View raw message