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

Bad Host header when using ingress nginx with custom errors #3018

Closed
lahsivjar opened this issue Aug 30, 2018 · 1 comment · Fixed by #3062
Closed

Bad Host header when using ingress nginx with custom errors #3018

lahsivjar opened this issue Aug 30, 2018 · 1 comment · Fixed by #3062

Comments

@lahsivjar
Copy link
Contributor

lahsivjar commented Aug 30, 2018

Is this a request for help? (If yes, you should use our troubleshooting guide and community support channels, see https://kubernetes.io/docs/tasks/debug-application-cluster/troubleshooting/.): No

What keywords did you search in NGINX Ingress controller issues before filing this one? (If you have found any duplicates, you should instead reply there.): upstream_balancer, bad host


Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT

NGINX Ingress controller version: 0.18.0

Kubernetes version (use kubectl version):

Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.4", GitCommit:"9befc2b8928a9426501d3bf62f72849d5cbcd5a3", GitTreeState:"clean", BuildDate:"2017-11-20T05:28:34Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.4", GitCommit:"9befc2b8928a9426501d3bf62f72849d5cbcd5a3", GitTreeState:"clean", BuildDate:"2017-11-20T05:17:43Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

Environment:

  • Cloud provider or hardware configuration: AWS (custom installation)
  • OS (e.g. from /etc/os-release): Ubuntu 16.04.3 LTS
  • Kernel (e.g. uname -a): Linux ip-10-7-65-14 4.4.0-1066-aws #76-Ubuntu SMP Thu Aug 16 16:21:21 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  • Install tools: Custom ansible scripts

What happened: ingress-nginx with custom-http-errors and Java + Tomcat based default backend fails with 400 bad request because nginx rewrites the Host header with upstream_balancer as per https://github.com/kubernetes/ingress-nginx/blob/master/rootfs/etc/nginx/template/nginx.tmpl#L715

What you expected to happen: Custom error pages are rendered

How to reproduce it (as minimally and precisely as possible): Use ingress-nginx with custom error pages and spring boot based default backend

Anything else we need to know:

The issue seems to happen because of Host header contains invalid characters (in this case the underscore as per [RFC952]: https://www.rfc-editor.org/rfc/rfc952.txt) and tomcat seems to not take it well. The issue can be fixed by one of the following:

  1. By modifying the upstream name to not contain the underscore
  2. By setting host header

If we can decide on the solution I can create a PR.

@lahsivjar
Copy link
Contributor Author

As a temporary solution, I have edited my nginx.tmpl to set Host header for custom errors. It will be really helpful if someone can take a look at the issue and suggest the correct approach to fix it (if required I can create PR to fix the issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant