Access log shows OriginStatus 502 when the connection to the origin server is refused

Hello everyone,

I have a question about originStatus field in Traefik access logs.

The Document says originStatus is the status code returned by the origin server.
However, when the connection to the origin server is refused, OriginStatus is set to 502. Since Traefik cannot communicate with the origin server, this is not from the server.

It this an expected behavior or should originStatus be empty?

(Since I'm new to Traefik and not sure whether this is expected, I made a topic instead of an issue.)

what I did to reproduce

    1. create a Kubernetes cluster by kind
    1. deploy Traefik and dependent resources following Quick Start with additional args below
    1. request to the origin server whoami through Traefik repeatedly
    1. kill the origin server
    1. get Traefik logs
  • additional args

args:
  - --api.insecure
  - --providers.kubernetesingress
  - --log.level=DEBUG
  - --accesslog=true
  - --accesslog.format=json

While the origin server is being deleted, Traefik responds 502 (and afterwards 404). Also, access log shows OriginStatus is 502 too.

time="2023-02-03T03:04:51Z" level=debug msg="'502 Bad Gateway' caused by: dial tcp 10.244.0.40:80: connect: connection refused"
{"ClientAddr":"127.0.0.1:36094","ClientHost":"127.0.0.1","ClientPort":"36094","ClientUsername":"-","DownstreamContentSize":11,"DownstreamStatus":502,"Duration":415201,"OriginContentSize":11,"OriginDuration":404530,"OriginStatus":502,"Overhead":10671,"RequestAddr":"localhost:5000","RequestContentSize":0,"RequestCount":123,"RequestHost":"localhost","RequestMethod":"GET","RequestPath":"/","RequestPort":"5000","RequestProtocol":"HTTP/1.1","RequestScheme":"http","RetryAttempts":0,"RouterName":"default-whoami-ingress@kubernetes","ServiceAddr":"10.244.0.40:80","ServiceName":"default-whoami-web@kubernetes","ServiceURL":{"Scheme":"http","Opaque":"","User":null,"Host":"10.244.0.40:80","Path":"","RawPath":"","OmitHost":false,"ForceQuery":false,"RawQuery":"","Fragment":"","RawFragment":""},"StartLocal":"2023-02-03T03:04:51.502911253Z","StartUTC":"2023-02-03T03:04:51.502911253Z","entryPointName":"http","level":"info","msg":"","time":"2023-02-03T03:04:51Z"}

On the other hand, 404 access log shows empty OriginStatus.

{"ClientAddr":"127.0.0.1:36170","ClientHost":"127.0.0.1","ClientPort":"36170","ClientUsername":"-","DownstreamContentSize":19,"DownstreamStatus":404,"Duration":14558,"Overhead":14558,"RequestAddr":"localhost:5000","RequestContentSize":0,"RequestCount":134,"RequestHost":"localhost","RequestMethod":"GET","RequestPath":"/","RequestPort":"5000","RequestProtocol":"HTTP/1.1","RequestScheme":"http","RetryAttempts":0,"StartLocal":"2023-02-03T03:04:53.80785313Z","StartUTC":"2023-02-03T03:04:53.80785313Z","level":"info","msg":"","time":"2023-02-03T03:04:53Z"}