Traefik should redirect to a service on 500 errors sent by cloudflare

Hello,

I have created an error page and a maintenance page served by a router and registered to traefik. I have created two middlewares: one for the 400-499 errors that redirect to the error page and one for the 500-599 errors that redirect to the maintenance page.
See my docker-compose.yml file for the configuration and the registration of the middlewares.

When I look for an unknown service, an error 404 is sent in response, and Traefik redirects to my error page but when I look for a service that is unavailable, CloudFlare sends a 50x error. Traefik receives the 50x error code but doesn't redirect to my maintenance page.

Here is an access log where Traefik receives the request with the 502 error but doesn't redirect to my maintenance page : [01/Jun/2022:16:52:10 +0000] "GET / HTTP/2.0" 502 11 "-" "-" 18786 "resume@docker" "http://172.18.0.3:3344" 0ms

I am looking for some help to solve my problem.

Arthur