httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: [users@httpd] Rewrite relative image paths in a reversed proxy setup
Date Mon, 17 Nov 2008 15:32:08 GMT
Bocalinda wrote:
> Maybe just a note before you go make all kinds of changes.
>> With an <img> tag like above, it is not so that the server will look in the
>> DocumentRoot.
>> You have to look at it the other way around.
>> The browser, when it sees this tag in the current page, is going to
>> "compose" a URL to retrieve it, on the base of :
>> - the URL at which it retrieved the current page (the one that contains the
>> <img> tag
>> - removing the last component (iow the name of the page itself)
>> - then substituting the "image.gif" part
>> In other words, if the current page was retrieved at :
>> and that page contains the tag above, then the browser will retrieve the
>> image at
>> The server has nothing to do with it, it just tries to deliver what is
>> requested by the browser.
> Thank you very much for your time.
> That makes perfectly sense.
> Then I guess I need to add a few more bits of information.
> I'm accessing my Apache server through a virtual IP address (LinuxHA + LVS).
> Say
> Thus I access my load balanced application through:
> Applying what you explained above, this would mean that my images paths will
> be resolved as:
> Which of course will not work.
Why "of course" ?
I may be thick, but I must admit I do not really understand your problem.

> As you can see, the image requests should be load balanced as well.
And they will be, according to your previous configuration.

>> Now, for your static elements like images, you have two choices :
>> - either you let things go as above, these requests will be forwarded to
>> Tomcat, will be balanced, and it means your images should be at the
>> corresponding locations in your Tomcat's
>> - or you do something at the Apache level that will prevent these URLs to
>> be passed to Tomcat, and you serve them locally at the Apache level.
>> In other words you exclude links ending in ".gif", ".jpg", ".xxx" from the
>> proxying.
> I'm afraid this won't be an option.

What I mean is : if the page your browser sees contains a tag <img 
href="image.gif">, the browser will resolve this according to the 
location from which it got the page that contains that link.
That's how browsers work, and are supposed to work.
If you do not want this, then do not put relative links in the pages, 
put absolute links.
Like <img href="/images/image.gif">.
The browser, mind you, will still resolve this according to the host 
from which it got your page, but this time will look for

But what do you want to happen, really ?
Where would you like the image to come from ?

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message