views:

329

answers:

1

I have servers spread across several data centers, each storing different files. I want users to be able to access the files on all servers through a single domain and have the individual servers return the files directly to the users.

The following shows a simple example:
1) The user's browser requests http://www.example.com/files/file1.zip
2) Request goes to server A, based on the DNS A record for example.com.
3) Server A analyzes the request and works out that /files/file1.zip is stored on server B.
4) Server A forwards the request to server B.
5) Server B returns file1.zip directly to the user without going through server A.

Note: steps 4 and 5 must be transparent to the user and cannot involve sending a redirect to the user as that would violate the requirement of a single domain.

From my research, what I want to achieve is called "Direct Server Return" and it is a common setup for load balancing. It is also sometimes called a half reverse proxy.

For step 4, it sounds like I need to do MAC Address Translation and then pass the request back onto the network and for servers outside the network of server A tunneling will be required.

For step 5, I simply need to configure server B, as per the real servers in a load balancing setup. Namely, server B should have server A's IP address on the loopback interface and it should not answer any ARP requests for that IP address.

My problem is how to actually achieve step 4?

I have found plenty of hardware and software that can do this for simple load balancing at layer 4, but these solutions fall short and cannot handle the kind of custom routing I require. It seems like I will need to roll my own solution.

Ideally, I would like to do the routing / forwarding at the web server level, i.e. in PHP or C# / ASP.net. However, I am open to doing it at a lower level such as Apache or IIS, or at an even lower level, i.e. a custom proxy service in front of everything.

A: 

Why not send an HTTP response of status code 307 Temporary Redirect?

At that point the client will re-request to the correct specified server.

I know you want a single domain, but you could have both individual subdomains plus a single common domain.

For example:

example.com has IP1, IP2, IP3.

example1.example.com has IP1
example2.example.com has IP2
example3.example.com has IP3

If the request comes to a server that it can't handle itself, it will forward the user to make another request to the correct specific server. An HTTP browser will follow this redirect transparently by the way.

Brian R. Bondy
That requires changing the domain. The location header would need to specify something other than www.example.com, e.g. www2.example.com, otherwise the request would just go straight back to the same server.If you're wondering why I cannot change the domain. It is because the files being served are flash swf files and most use local storage, which requires the domain/subdomain stay constant. FYI, I have already tried all the 30x redirects and none are transparent to flash.
Daniel Crabtree
Thanks for the explanation.
Brian R. Bondy