Hi, I'm looking for solution how to get in Lua code the reason of connect() (and other) error when request goes to problem upstream.
I would like to display on custom 5xx page detailed info about reason of error, for example Connection refused by upstream.
I tried https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/balancer.md#get_last_failure but this method doesn't provide explained details about reason of failure.
lua err:
[error] [lua] balancer_by_lua:22: state_name: failed, status_code: 502 while connecting to upstream
and basic nginx err:
[error] connect() failed (111: Connection refused) while connecting to upstream
Of course, I can do pre-upstream check via https://github.com/openresty/lua-nginx-module#tcpsockconnect
but doing additional connections for each request - overkill.
Probably there is another right solution. Looking for you help and advice.
p.s. If it is not possible to implement on Lua side, may be external nginx module can do it? If there is no one - we can discuss the development.