Skip to content

Latest commit

 

History

History
94 lines (74 loc) · 4.1 KB

README.md

File metadata and controls

94 lines (74 loc) · 4.1 KB

Custom error pages for your traefik installation.

Docker Image Version (tag latest semver) Docker Image Size (tag) Docker Pulls GitHub Tag Build Status GitHub Last Commit License: MIT Awesome Badges

Image

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

Usage

To use the error pages you have to do these two steps:

1. Setup error service

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

2. Configure traefik middleware

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

Kubernetes

If you want to use this tool inside of a Kubernetes cluster check out my ready to deploy Helm chart!

License

MIT – © 2023 Pascal Iske