How do I define the error middleware for multiple status codes?

My use-case is that I would like a custom error page only for codes 404 and 502. Most natural to me would be a definition:

traefik.http.middlewares.status-pages-middleware.errors.status=404,502

This possibility was actually raised in the original pull request https://github.com/traefik/traefik/pull/1675 but not implemented as far as I can tell.

Do I need to define two different middlewares pointing to the same service for covering this use-case or what is the best approach?

The reference pages suggest your format is correct.

  - "traefik.http.middlewares.middleware08.errors.status=foobar, foobar"

https://doc.traefik.io/traefik/reference/dynamic-configuration/docker/

1 Like

Oh, I will test that. It did not become clear to me from Errors - Traefik which I was looking at. Do you think a mix of a list and a range is supported, too? Something like 404,500-599?

I think, yes. I know, no. :smiley:

Ran some tests and yes, it does work! Maybe this would be useful to add to the docs Errors - Traefik ?

1 Like

Create an issue, or better yet a PR !

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.