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.

I want to reverse-proxy to a server through nginx and, based on the response (for example, a 4xx) forward the request onto a second proxy. So when a request comes in, nxinx passes it onto the first. If the first gives a non-error response then it should return as normal. If it returns an error then nginx should send it to the second and return that response.

From a cursory reading of the documentation I don't think I can do this just through the config. I can write an nginx extension to do this, but I thought I'd ask in case it's possible without writing extra code.

share|improve this question
    
I am a little unclear about the flow of traffic here. To clarify, if the a backend server of the first reverse proxy returns a 404 code, you then want to send this response to another proxy? –  jeffatrackaid May 31 '13 at 15:47
    
Wrong. You are entirely clear about what I'm after. –  Joe May 31 '13 at 16:06
    
I don't think what you state is possible with standard configuration. I don't think there is a way to intercept the response and conditionally re-process it. I know you asked about Nginx, but Varnish has methods to re-process requests from the backend. See varnish-cache.org/trac/wiki/VCLExampleRestarts –  jeffatrackaid May 31 '13 at 16:23
    
Thank you. I thought not. If you give this as an answer I'll accept it if no-one else can say otherwise. –  Joe Jun 1 '13 at 19:22

1 Answer 1

up vote 1 down vote accepted

I don't think what you state is possible with standard configuration. I don't think there is a way to intercept the response and conditionally re-process it.

Also, even if you write a module, latency could be an issue. You would need to make 2 roundtrips on the backend just to send data to the client.

I know you asked about Nginx, but Varnish has methods to re-process requests from the backend. See varnish-cache.org/trac/wiki/VCLExampleRestarts

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.