/traefik-custom-error-pages

Bunch of custom error pages for Traefik 2.x built with Jekyll

Primary LanguageCSSMIT LicenseMIT

Donate Docker Pulls Docker Stars Netlify Status

⚠️ DEPRECATION WARNING ⚠️

I'm not using this image anymore. I switched from Traefik to Caddy because Traefik is far too complicated for my needs. This image works as it. If you want new features, feel free to fork the project.

Custom error pages for Traefik

A bunch of custom error pages for Traefik built with Jekyll.

Development

Install dependencies

$ bundle install

If you want to build the project on your host:

$ jekyll build

If you want to preview the pages before building the Docker image :

$ jekyll serve

Open http://127.0.0.1:4000/.

How to use with Traefik and Docker in Production

Run the container with labels, change with your needs:

# docker-compose.yml

errorpage:
  image: guillaumebriday/traefik-custom-error-pages
  restart: unless-stopped
  networks:
    - web
  labels:
    - traefik.enable: "true"
    - traefik.docker.network: "web"
    - traefik.http.routers.errorpage.entrypoints: "websecure"
    - traefik.http.routers.errorpage.rule: "HostRegexp(`{host:.+}`)"
    - traefik.http.services.globalerrorpage.loadbalancer.server.port: "80"

Build the image

This is a multi-stage build, to build the final image:

$ docker build -f .cloud/docker/Dockerfile -t traefik-custom-error-pages .

How it works?

As you can see in the Dockerfile, I use Nginx as Web server to serve static files. To generate this pages, I use Jekyll in the first step of the build.

You will find in this article https://www.techjunktrunk.com/docker/2017/11/03/traefik-default-server-catch-all why I set up rule this way.

It's very useful because this container will respond to all requests only if there is no container with a real rule.

Credits

I used the Laravel default HTTP error pages.

Contributing

Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.

License

This project is released under the MIT license.