I have installed the ingress controller using the link : https://cloud.google.com/community/tutorials/nginx-ingress-gke
which is up and running
NAME TYPE CLUSTER-I EXTERNAL-IP PORT(S)
nginx-ingress-controller LoadBalancer X.X.X.X X.X.X.X1 80:123/TCP,443:456/TCP
After that I have installed and exposed the application as nodePort, bot app up and running.
Ingress Rules are defined as mentioned in attachment :
To very I did exec in inginx-controller pod and test the followings:
Tests: 1
Input : curl localhost
Output : default backend - 404
Tests: 2
Input : curl localhost -H 'Host:foo.com'
Output : app working properly
Tests: 3
Input : curl localhost -H 'Host:faa.com'
Output : app working properly
Tests: 4 on Browser Chrome
Input : foo.com
Input : faa.com
Output : default backend - 404
I'm not able to figureout where am I missing to recheck
Please support me for for the same.
I know it's late, but somebody might have similar situation.
In my case, problem was next:
When executing curl command:
curl http://<ip-address>:<k8s-svc-port> -H 'Host:foo.com'
HTTP request looks something like:
GET / HTTP/1.1
Host: foo.com
User-Agent: curl/7.64.0
Accept: */*
When executing in browser, http request looks something like this: firefox http request example
Host: foo.com:32009
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
...
And that's the difference, because haproxy ingress controller looks for host field of http request. In this case,
- curl sets header Host:foo.com
- browser sets header Host:foo.com:32009, which is not recognized by haproxy
(haproxy expects foo.com and gets foo.com:32009)
So, ingress controller works fine, it's the browsers http request that's making problem.
I hope this can be helpful.
Upon looking at your YAML file, I can see that you do not have a 'default backend' in the Ingress service. The 'default backend' will define the rules to take if the page results in an error 404.
The ‘default backend’ is different from the backend
under the path
. The default backend has to be right under the spec
.
For more information on the default backend, you may read through the k8s documentation
This is the how you should define a default backend in your YAML file.
spec:
backend:
For the same reason, it is not working on the chrome browser. There is no 'default backend'.