Custom error pages for your traefik installation.
Registry | Image |
---|---|
Docker Hub | pascaliske/traefik-errors |
GitHub | ghcr.io/pascaliske/traefik-errors |
The following platforms are available for this image:
$ docker run --rm mplatform/mquery pascaliske/traefik-errors:latest
Image: pascaliske/traefik-errors:latest
* Manifest List: Yes
* Supported platforms:
- linux/amd64
- linux/arm/v7
- linux/arm64
To use the error pages you have to do these two steps:
The easiest way to use the service is docker-compose
:
version: '3.7'
services:
# proxy
traefik:
image: traefik:latest
container_name: traefik
ports:
- '80:80'
command:
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --entrypoints.http.address=:80
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /path/to/traefik/config:/etc/traefik
# custom error pages
traefik-errors:
image: ghcr.io/pascaliske/traefik-errors:latest # or: pascaliske/traefik-errors:latest
container_name: traefik-errors
labels:
- traefik.enable=true
- traefik.http.routers.traefik-errors.rule=HostRegexp(`{host:.+}`)
- traefik.http.routers.traefik-errors.entrypoints=http
- traefik.http.routers.traefik-errors.priority=1
- traefik.http.routers.traefik-errors.middlewares=error-pages@file
# demo service
whoami:
image: traefik/whoami
container_name: whoami
labels:
- traefik.enable=true
- traefik.http.routers.whoami.rule=Host(`whoami.domain.tld`)
- traefik.http.routers.whoami.entrypoints=http
- traefik.http.routers.whoami.middlewares=error-pages@file
Create a dynamic config file for traefik:
http:
middlewares:
error-pages:
errors:
service: traefik-errors
query: "/?code={status}&home=domain.tld" # home parameter is optional
status:
- 400-599
If you want to use this tool inside of a Kubernetes cluster check out my ready to deploy Helm chart!
MIT – © 2023 Pascal Iske