The `set_more_tries` function can allow `balancer_by_lua` to be invoked multiple times during a single request. For example, if you call `set_more_tries(1)` before the request is sent to the upstream, if the upstream request fails with a status code configured in `proxy_next_upstream`, `balancer_by_lua` will be called again for the request. You can continue to call `set_more_tries`, and NGINX will continue to invoke `balancer_by_lua` on failures until you've reached `proxy_next_upstream_tries` at which point the downstream request will fail.
It's up to you to decide how to respond to a failing upstream. You can call `set_current_peer` and simply set different host/port upstream if/when the upstream request fails.
On Tuesday, 14 June 2016 10:56:40 UTC-4, RJoshi wrote:
Hello,
Based on the proxy_next_upstream, Nginx can retry to the next configure server in the upstream directive.
How can we achieve this with balancer_by_lua? It allows to set only one peer host/port.
Thanks,
Rohit Joshi