Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

If you access a file via a reverse proxy and the file is not found (returns 404), can apache2/mod_proxy automatically check for the file on another server by doing another reverse proxy?

workflow is like so: 1. request the file on the server doing the reverse proxy 2. server looks for the file on server A 3. file not found on server A, so it checks server B 4. file was found on server B, so it gets returned.

I already know other offerings can do this, but I was curious if mod_proxy can do this?

share|improve this question
    
I would take a step back and ask, why does one backend server have the file and another doesn't? –  KM. Feb 6 '12 at 15:04

1 Answer 1

up vote 2 down vote accepted

There is way, but not using 404, and to be honest it's a bad idea.

First, set maxattempts to a number bigger than 1. Set nofailover to Off.

Then in the backend that does not hold the object you want, you return a 503 when you want it to try the next one. (503 = HTTP_SERVICE_UNAVAILABLE)

This won't work in the real life though. Apache has no way of guessing what's a real 503 error, and what's a "try the other server" error. In other words, it will break the real 404 detection. There will be no way of issuing a 404 "page not found" error, since you'll always will return "service unavailable" errors to the users after apache gives up trying all servers.

Besides, the thing you're trying to do here is not a good idea, IMHO. You should configure proper mappings on your Apache Proxy, and assign servers based on the URLs of your requests.

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#forwardreverse

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.