We are using custom_nginx.template to custom some nginx configurations. We have customized nginx errors in this file using the error_page
directive
error_page 500 501 502 508 /our_error_handling_location;
After upgrading to Kong 2.3.1, we noticed the the error_response
directive dose not affect 502 status code anymore. In case of connectivity issue, the response is
{
"message": "An invalid response was received from the upstream server",
"statusCode": 502
}
instead of our custimized response.
We figured out that the following code in kong/init.lua
is responsible to this behaviour
local res = ngx.location.capture("/kong_buffered_http", options)
if res.truncated then
kong_global.set_phase(kong, PHASES.error)
ngx.status = 502
return kong_error_handlers(ctx)
end
Is there any way to customize this error?