tzssangglass commented on a change in pull request #6392:
URL: https://github.com/apache/apisix/pull/6392#discussion_r810758089



##########
File path: apisix/init.lua
##########
@@ -589,25 +589,33 @@ function _M.http_header_filter_phase()
     core.response.set_header("Server", ver_header)
 
     local up_status = get_var("upstream_status")
-    if up_status and #up_status == 3
-       and tonumber(up_status) >= 500
-       and tonumber(up_status) <= 599
-    then
-        set_resp_upstream_status(up_status)
-    elseif up_status and #up_status > 3 then
-        -- the up_status can be "502, 502" or "502, 502 : "
-        local last_status
-        if str_byte(up_status, -1) == str_byte(" ") then
-            last_status = str_sub(up_status, -6, -3)
+    if up_status then
+        local_conf = core.config.local_conf();
+        if local_conf.apisix and local_conf.apisix.enable_all_upstream_status 
then
+            set_resp_upstream_status(up_status)
         else
-            last_status = str_sub(up_status, -3)
-        end
+            if #up_status == 3
+                    and tonumber(up_status) >= 500
+                    and tonumber(up_status) <= 599
+            then
+                set_resp_upstream_status(up_status)
+            elseif #up_status > 3 then
+                -- the up_status can be "502, 502" or "502, 502 : "
+                local last_status
+                if str_byte(up_status, -1) == str_byte(" ") then
+                    last_status = str_sub(up_status, -6, -3)
+                else
+                    last_status = str_sub(up_status, -3)
+                end
 
-        if tonumber(last_status) >= 500 and tonumber(last_status) <= 599 then
-            set_resp_upstream_status(up_status)
+                if tonumber(last_status) >= 500 and tonumber(last_status) <= 
599 then
+                    set_resp_upstream_status(up_status)
+                end
+            end
         end
     end
 
+

Review comment:
       delete this blank line

##########
File path: docs/zh/latest/debug-function.md
##########
@@ -23,7 +23,7 @@ title: 调试功能
 
 ## `5xx` 响应状态码
 
-500、502、503 等类似的 `5xx` 状态码,是由于服务器错误而响应的状态码,当一个请求出现 `5xx` 状态码时;它可能来源于 `APISIX` 
或 `Upstream` 。如何识别这些响应状态码的来源,是一件很有意义的事,它能够快速的帮助我们确定问题的所在。
+500、502、503 等类似的 `5xx` 状态码,是由于服务器错误而响应的状态码,当一个请求出现 `5xx` 状态码时;它可能来源于 `APISIX` 
或 `Upstream` 。如何识别这些响应状态码的来源,是一件很有意义的事,它能够快速的帮助我们确定问题的所在。(当修改 `conf/nginx.conf` 
的配置 `enable_all_upstream_status` 为 true 时,会将上游所有状态都返回,不仅仅是5XX状态。)

Review comment:
       ```suggestion
   500、502、503 等类似的 `5xx` 状态码,是由于服务器错误而响应的状态码,当一个请求出现 `5xx` 状态码时;它可能来源于 
`APISIX` 或 `Upstream` 。如何识别这些响应状态码的来源,是一件很有意义的事,它能够快速的帮助我们确定问题的所在。(当修改 
`conf/nginx.conf` 的配置 `enable_all_upstream_status` 为 true 时,会返回所有上游状态码,不仅仅是 
`5xx` 状态码。)
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to