On Wednesday, March 16, 2016 at 1:08:17 PM UTC-7, agentzh wrote:
Hello!
On Sun, Mar 13, 2016 at 10:51 PM, Hao Wu wrote:
> when the backend server sends back the error messages (404 or 500), I will
> need to inspect it before it moves to the next server. right now, I can set
> retry so the upstream will do it for me (proxy_next_upstream directive) and
> the script will get run when it already moves to the next server. basically,
> I need to do a bit more than header check when the backend server comes back
> with error messages.
>
Sorry, I don't think I quite understand your requirement here. Will
you elaborate the "a bit more" part? Better with psuedo code snippets
if they can help.
Can we have some hooks like what proxy_next_upstream does? i.e.
next_stream_by_lua_block {
if (upstream.connection is broken)
return true
end
if (upstream.status == 404 and upstream.body contains "XXX") then
return true; -- this will try the next upstream
else
return false; -- this will forward back to the client
end
}
and the body will be only read to the memory if it is being accessed and/or to avoid to read the full body response, some API can be like, upstream.getBody(range),
is this possible?
Regards,
-agentzh