$upstream_status may show 502 even if upstream replied with 503

My nginx.conf:
http {

upstream test {
server max_fails=0;
server max_fails=0;

server {
listen 8080;
location / {
proxy_pass http://test;
proxy_next_upstream http_503;
proxy_intercept_errors on;

log_format main ‘$upstream_status’;


If my upstream servers are on and always reply with 503 I expect to find
503, 503
Instead I find
502, 503
Is it ok that first upstream status is 502 instead of 503?

Can I somehow configure nginx to show 503?
Because in case of more complicated
proxy_next_upstream error http_503
it is more useful to see fair upstream status to distinguish between
and http_503.

Posted at Nginx Forum: