Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ingress-nginx-defaultbackend overrides application's 404 error #12446

Closed
abhiverma001 opened this issue Dec 6, 2024 · 6 comments
Closed

Ingress-nginx-defaultbackend overrides application's 404 error #12446

abhiverma001 opened this issue Dec 6, 2024 · 6 comments
Labels
kind/support Categorizes issue or PR as a support question. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@abhiverma001
Copy link

Here is configuration what I have done to route the 404 and 503 errors on defaultbackend:

  • Defined custom HTML pages for 404 and 503 errors in a ConfigMap called custom-error-pages.
  • Enabled the defaultBackend in the ingress-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 the custom-http-errors key with values 404,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.....

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Dec 6, 2024
@k8s-ci-robot
Copy link
Contributor

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.

@k8s-ci-robot k8s-ci-robot added needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority labels Dec 6, 2024
@longwuyuan
Copy link
Contributor

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.

@longwuyuan
Copy link
Contributor

/kind support

@k8s-ci-robot k8s-ci-robot added kind/support Categorizes issue or PR as a support question. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Dec 6, 2024
@abhiverma001
Copy link
Author

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

@longwuyuan
Copy link
Contributor

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

@abhiverma001
Copy link
Author

abhiverma001 commented Dec 12, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
Development

No branches or pull requests

3 participants