Custom error pages with traefik v2

Hi,
im running custom error pages on my traefik v1 services.
So i wanted to implement that also with traefik v2 but i don't get it working.

Does someone has an example using and defining a custom error page service with Version 2 ?

Hi @lachnerd, can you share the configurations with us so we can help you?

Sure,
but i got it working now (don't know the reason maybe a typo or something else) but maybe it helps others.

I have a service servingh the error pages defined in rancher with following labels:

# errorhandler@rancher
labels:
      traefik.http.services.errorhandler.loadbalancer.server.port: '80'
      traefik.enable: 'true'
      #only for testing
      traefik.http.routers.errorhandler.rule: Host(`error.domain.com`)
      io.rancher.container.pull_image: always
      traefik.http.routers.nginx.entrypoints: web

In a file provided dynamic_conf.toml i defined the middleware

# errortest@file
[http.middlewares]
  [http.middlewares.errortest.errors]
       status = ["400-404","405","500","502-504"]
       service = "errorhandler@rancher"
       query = "/{status}.html"

the app that uses custom error pages simply uses the middleware with another label:

# simpleapp@rancher
labels:
  traefik.http.routers.simpleapp.middlewares: errortest@file
1 Like