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.

    1. $ curl http://127.0.0.1:9080/hello -v
    2. ......
    3. < HTTP/1.1 502 Bad Gateway
    4. < Date: Wed, 25 Nov 2020 14:40:22 GMT
    5. < Content-Type: text/html; charset=utf-8
    6. < Content-Length: 154
    7. < Connection: keep-alive
    8. < Server: APISIX/2.0
    9. <
    10. <html>
    11. <head><title>502 Bad Gateway</title></head>
    12. <body>
    13. <center><h1>502 Bad Gateway</h1></center>
    14. <hr><center>openresty</center>
    15. </body>

    It has a response header of X-APISIX-Upstream-Status: 502.

    1. $ curl http://127.0.0.1:9080/hello -v
    2. ......
    3. < HTTP/1.1 500 Internal Server Error
    4. < Content-Type: text/plain; charset=utf-8
    5. < Transfer-Encoding: chunked
    6. < Connection: keep-alive
    7. < Server: APISIX/2.0
    8. <
    9. Fault Injection!

    There is no response header for X-APISIX-Upstream-Status.

    1. $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
    2. {
    3. "uri": "/hello",
    4. "upstream_id": "1"

    It has a response header of X-APISIX-Upstream-Status: 502, 502, 502.