Warning: This repository is Proof Of Concept.
This is default backend for Nginx ingress Controller. It is based on the example error backend with predefined error pages and Go templating. We have fixed some errors and added few new ones.
We used haproxy error pages from Jonathan Rosewood as a base for the error messages. Thank you.
# build static image
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o custom-error-pages
# run
DEBUG=1 ERROR_FILES_PATH=./rootfs/www ./custom-error-pages
# run with custom error pages
DEBUG=1 ERROR_FILES_PATH=./rootfs/www CUSTOM_ERROR_FILES_PATH=./rootfs/www.override ./custom-error-pages
# test in other terminal
curl localhost:8080 -H 'X-Code: 502' -I
curl localhost:8081/metrics
There is default HTTP backend on port 8080. You should use this as your ingress default backend.
There is secondary port 8081, which can be used for health checking (on /healthz
URI) and monitoring (/metrics
)
# build static Docker image
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o custom-error-pages
docker build -t localhost/custom-error -f Dockerfile.devel .
# run and test the image
docker run --rm -it -e DEBUG=1 -p 8080:8080 -p 8081:8081 localhost/custom-error:latest
-
deploy the image to Deployment
-
deply Service named
default-backend
to some namespace ( we useingress-nginx
) -
according to the ingress parameters, update command line arguments to set default backend.
--default-backend-service=ingress-nginx/default-backend
-
Add
custom-http-errors: 503,502,403
to ingress config map. -
Watch metrics
default_http_backend_http_error_count_total > 0
.
Example manifests are available at GitHub repository. You still have to modify ingress config.
Apache 2 (same as from original example)