kubernetes-ingress
kubernetes-ingress copied to clipboard
Custom error page for 404, 503 errors
Is your feature request related to a problem? Please describe.
With reference to the previous issue https://github.com/nginxinc/kubernetes-ingress/issues/752, we are trying to apply a custom error page across the services using nginx ingress. Describe the solution you'd like
We want a solution like the community version is providing through the defaultbackend container. https://kubernetes.github.io/ingress-nginx/examples/customization/custom-errors/ Describe alternatives you've considered No, We cant change it as it is already rolled out. Additional context
Hi @meektechie thanks for reporting!
Be sure to check out the docs and the Contributing Guidelines while you wait for a human to take a look at this :slightly_smiling_face:
Cheers!
@meektechie this is currently something we address through the project custom resources today: https://docs.nginx.com/nginx-ingress-controller/configuration/virtualserver-and-virtualserverroute-resources/#errorpage
However, that capability is built to handle API Gateway style behavior that is commonly custom per hostname or path.
Since you mention the default backend behavior. Are you looking for a catch-all when no hostnames or paths match? Rather than the default NGINX behavior of no response when there is no match, you are looking for programming a response. Is that correct?
And I am also making the assumption that your organization is committed to the Ingress resource exclusively. Is that also correct?
Yes You are right, We are looking to catch all when no hostnaes or paths match. We just want to add a custom error page/html file instead of the default 404 response. That response will be very simple, something like "Not Found" since the response code is already captured under response header.
Have you discovered: https://docs.nginx.com/nginx-ingress-controller/configuration/global-configuration/configmap-resource/#:~:text=False-,default%2Dserver%2Dreturn,-Configures%20the%20return To see how close this is to what you are looking for?
@meektechie you can use the item @brianehlert mentioned to redirect any unknown hostname/resources. Here is a small example:
apiVersion: v1
data:
default-server-return: 302 https://nginx.org
kind: ConfigMap
metadata:
name: nginx-config
namespace: nginx-ingress
Basically, any unmatched resources will be sent a 302 and redirected to https://nginx.org HTH
Thanks for sharing this, I already went through this. I need to apply a custom response for the 404 page but the custom response always goes to 302.
With this page, i want to cusomize.
400 Bad Request
Idea:
Use another URL that is also hosted under a different path as the redirect and back it with a very small web server service and your page. http://foo.com/404.html
Then it can be HTTP and get picked up by any HTTP to HTTPS behavior that is set for the hostname.
Since the 30x happens at the client side anyway it is not a forward (aka proxy_pass).
Hi @meektechie has your issue been resolved? Are you happy to close the issue?
Nope, it isn't working
highlighting this as still not resolved
Hi @meektechie Are you using an Ingress resource or a VirtualServer/VirtualServerRoute resource?
If you happen to be using VirtualServer & VirtualServerRoutes , we allow error pages to be customised using our ErrorPage feature.