2

Say I have this URL to an image:

www.domain.com/image.jpg

And I want to have image.jpg actually be served from another server entirely (different machine and IP), at

static.domain.com/image.jpg

Is it possible to configure Apache in such a way that any requests to www.domain.com/image.jpg are actually completely served by static.domain.com/image.jpg, but to the user it looks like it is coming from www.domain.com/image.jpg?

1
  • Why bother with obscurity? A 2nd domain for static content is widely used - e.g. Google - *.gstatic.com & Facebook - *.fbcdn.net. If you proxy, it will be transparent, but you will consume bandwidth on the proxy (and lose the concurrency of a 2nd domain) - the request goes through the proxy in both directions. You could implement a rewrite, which will send the browser to the other domain - it adds an extra step (and latency) for each request, doesn't consume much bandwidth on the proxy (www.domain.com), and your link could use www.domain.com (but the user can detect it - e.g. using Firebug).
    – cyberx86
    Nov 27, 2011 at 3:00

2 Answers 2

4

No matter what you do, if you try to serve content from multiple servers using a single outward-facing address, you are going to have to somehow get the content down the TCP connection that was established to www.domain.com to start with, because it's not technically feasible to "hand over" an established TCP connection to another machine.

Your only option is to use a redirect - which is detectable. But why bother, except possibly so avoid breaking incoming hyperlinks? The web was intended from the beginning to let a single web page contain information from multiple servers.

So keep it simple! :-) And if you use a seperate hostname for your static files, you'll be in good company.

2

This might be possible if you have control over the switch your servers are on. You would need to make use of Direct Server Return. This is a pretty advanced setup though, and probably doesn't make a lot of sense unless you have a large number of machines.

The far better solution is to just serve the content directly from static.domain.com. Even if you have to pay for an extra SSL certificate, it's going to come out far cheaper in terms of the amount of time you spend on it. If this isn't an option for you, please tell us why.

You must log in to answer this question.

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