Debug Function
In the response header of the request, through the response header of X-APISIX-Upstream-Status
, we can effectively identify the source of the 5xx
status code. When the 5xx
status code comes from Upstream
, the response header X-APISIX-Upstream-Status
can be seen in the response header, and the value of this response header is the response status code. When the 5xx
status code is derived from APISIX
, there is no response header information of X-APISIX-Upstream-Status
in the response header. That is, only when the status code of is derived from Upstream will the X-APISIX-Upstream-Status
response header appear.
$ curl http://127.0.0.1:9080/hello -v
......
< HTTP/1.1 502 Bad Gateway
< Date: Wed, 25 Nov 2020 14:40:22 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 154
< Connection: keep-alive
< Server: APISIX/2.0
<
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>openresty</center>
</body>
It has a response header of X-APISIX-Upstream-Status: 502
.
$ curl http://127.0.0.1:9080/hello -v
......
< HTTP/1.1 500 Internal Server Error
< Content-Type: text/plain; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Server: APISIX/2.0
<
Fault Injection!
There is no response header for X-APISIX-Upstream-Status
.
$ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/hello",
"upstream_id": "1"
It has a response header of X-APISIX-Upstream-Status: 502, 502, 502
.