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://172.18.0.39:8009 route=vdebian1
        BalancerMember ajp://172.18.0.40:8009 route=vdebian2
</Proxy>

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

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

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

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
</LocationMatch>

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
request.
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) http://172.18.0.39:8080/$1 Rie
</Location>

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.

Reply via email to