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.