Skip to content

caktus/custom-error-pages

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Custom Error Pages in Kubernetes

The Dockerfile in this repo builds an image that can be used in a kubernetes deployment to supply custom error pages for nginx, as described in the Kubernetes Ingress documentation.

How to Use

I'm planning to add support to Caktus's k8s-web-cluster Ansible role which will automatically reference this image, creating a service and deployment named nginx-errors in your cluster. That service will be used as the default-backend for the ingress-nginx controller, so it will use the image in this repo to return HTML pages for the error codes that you specify.

How to customize

If you want to customize the error pages that you show, you'll need to fork this repo, update the contents of the www directory, and then push your built images to a place that your Kubernetes cluster can access them.

Initial setup

  1. Create a Container Registry Personal Access Token (CR_PAT), giving it the write:packages and read:packages permissions. (Clicking write:packages will automatically select the repo permissions, so you should manually unselect repo to minimize the permissions that you give this key.

  2. Add that token to your environment (e.g. in .envrc):

    export CR_PAT_KEY=supersecrettoken
    
  3. Login to the registry:

    echo $CR_PAT | docker login ghcr.io -u <USERNAME> --password-stdin
    
  4. Push the image:

    docker push ghcr.io/caktus/custom-error-pages:latest
    

Updating this repo

Every push to the master branch will get run by Github Actions and a new docker image will be build and pushed to the Github Container Repository with a tag of latest: https://github.com/orgs/caktus/packages/container/package/custom-error-pages

If you add a git tag to the master branch with a v prefix, then Github Actions will build an image with that tag (without the v prefix). So tagging the master branch with v1.0 and pushing it will result in this image being built:

ghcr.io/caktus/custom-error-pages:1.0

References / Inspirations