Custom errorpage on Traefik it's own IP

Hi,

Is it possible to apply this way of error-pages on the IP of Traefik? When you access the IP of Traefik directly then you still get the blanc 404 errorpage which I like to avoid, the same goes for Bad Gateway, etc.

https://raw.githubusercontent.com/Midnighter/errorpages-demo/main/docker-compose.yml

Would be great to know how!

For existing domains you need to add the error middleware, for non existing (maybe like IP) you can just create an additional catch-all router and apply the error middleware:

.rule:HostRegexp(`{host:.+}`)

All non-existant domainnames are already in the catch-all container rules ?

That's what I would expect, yes.

OK, so what woud be your idea ? Could you give a full example maybe as I don't succeed here it seems.

You referenced a config. That does not work? What’s the exact problem?

The issue is, when you visit the pubic IP of the Traefik container you still get the default 404 error page and not a custom one.

I would recommend to check it step by step. This docker-compose.yml enables a catchall on port 80, it works with domain name and plain IP, shows a simple whoami page:

version: '3.9'

services:
  traefik:
    image: traefik:v2.9.6
    ports:
      - target: 80
        published: 80
        protocol: tcp
        mode: host
    networks:
      - proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    command:
      - --providers.docker=true
      - --providers.docker.exposedByDefault=false
      - --entryPoints.web.address=:80
      - --log.level=DEBUG
      - --accesslog=true

  catchall:
    image: traefik/whoami:v1.8
    hostname: catchall
    networks:
      - proxy
    labels:
      - traefik.enable=true
      - traefik.http.routers.catchall.entrypoints=web
      - traefik.http.routers.catchall.rule=HostRegexp(`{host:.+}`)
      - traefik.http.routers.catchall.priority=1
      - traefik.http.services.catchall.loadbalancer.server.port=80
      #- traefik.http.routers.catchall.middlewares=redirectall
      #- traefik.http.middlewares.redirectall.redirectregex.regex=.*
      #- traefik.http.middlewares.redirectall.redirectregex.replacement=https://example.com

networks:
  proxy:
    name: proxy
    external: true