Hello fellows,
I'm facing the following problem: when we are reverse proxying our clients' origins with single server upstreams, everything work as expected, we can capture errors using proxy_intercept_errors and then deliver error pages that are hosted by them. When we have configurations with load balancing and proxy_next_upstream, if request receives a 403 for example, nginx tries every server in upstream and, if max_tries is reached, they are removed from balancing and we can't deliver an error page from the origin, by there's no live upstream.
As a workaround, I can create a backup upstream that would be used as proxy_pass by a location that is called only by an error_page directive. But as we're moving towards more flexible configurations, using as much Lua code as possible, if possible I'd like to treat these errors in header_filter_by_lua_block, when I'd have already received proxy status. But I could not figure how to issue a new request to retrieve error pages, as subrequests are not available at this point.
Do you have any suggestions on how to deliver clients' error pages using Lua code?
Thank you very much!