Ingress-nginx-defaultbackend overrides application's 404 error
abhiverma001 opened this issue · 6 comments
Here is configuration what I have done to route the 404 and 503 errors on defaultbackend:
- Defined custom HTML pages for
404
and503
errors in a ConfigMap calledcustom-error-pages
. - Enabled the
defaultBackend
in theingress-nginx
Helm chart. - Mounted the
custom-error-pages
ConfigMap as a volume to the default backend Pod. - Set up
extraVolumeMounts
to serve the custom HTML files. - Edited the
ingress-nginx-controller
ConfigMap to include thecustom-http-errors
key with values404,503
to indicate these errors should be served by the default backend.
It is working as per the expectation but there is an issue, With this configuration default-backend
overrides the applications's 404 errors also, I don't want that, If any application returns a 404 error then it should use that page only, traffice should not be routed on default-backend pod at that time.
If any one can help here to fix this please.....
This issue is currently awaiting triage.
If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted
label and provide further guidance.
The triage/accepted
label can be added by org members by writing /triage accepted
in a comment.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
You said you configured 404 in the configMap and you also say you don't want 404 to be response from defaultbackend. This is not possible.
/kind support
You said you configured 404 in the configMap and you also say you don't want 404 to be response from defaultbackend. This is not possible.
Ofcourese I want 404 response from defaultbackend but only for unmatched paths (404) in ingress.
and If ingress path is matched but the application/api (running inside the pod) returns 404 error at that time don't want to redirect the traffice on default-backend instead error should be appear exactly same what application returns
I am not sure if there is that intelligence in the controller code.
I think you need to dive into the nginx.conf directives that provide this functionality https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#custom-http-errors
It is fixed by removing the 404 value form custom-http-errors
key in ingress-nginx-controller
ConfigMap
And even removing this 404 for unmathched path traffice is still being routed to default-backend and also now application's 404 error is not being over ride by default-backend.