istio: 0.8 Not being able to use hosts different of "*" on VirtualService for (Ingress) Gateways
Hi.
Istio 0.8 running on IBM Cloud Private 2.1.0.2 with k8s 1.9.1
When I tray to set a hostname instead of the wildecard “*” in the VirtualService “hosts” I always get 404 code.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bookinfo
spec:
hosts:
- "books.example.com" (instead of "*")
These are my objects:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: bookinfo-gateway
spec:
selector:
istio: ingressgateway # use istio default controller
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "books.example.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bookinfo
spec:
hosts:
- "books.example.com"
gateways:
- bookinfo-gateway
http:
- match:
- uri:
exact: /productpage
- uri:
exact: /login
- uri:
exact: /logout
- uri:
prefix: /api/v1/products
route:
- destination:
host: productpage.istio-apps.svc.cluster.local
port:
number: 9080
I also tested without quotes so books.example.com instead of “books.example.com”
I have tried also with the example described in https://istio.io/docs/tasks/traffic-management/ingress/
I the logs of the pod istio-ingressgateway-xxxx this is the trace:
Calling http://books.example.com:31380/productpage in the browser
[2018-06-03T07:34:08.917Z] “GET /productpage HTTP/1.1” 404 NR 0 0 2 - “10.186.234.215” “Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36” “b9ef69ff-cb28-993d-b1b8-5d3aa8df6cb4” “books.example.com:31380” “-”
31380 is the nodeport of istio-ingressgateway pointing to port 80.
If I substitute the hosts “books.example.com” with “*” it works.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (15 by maintainers)
@jxadro Also test your case as follows:
The log from productpage istio-proxy:
So when using curl I have to set the host header:
-H "Host: books.example.com"
, the reason is because the port comes into play with Istio and Envoy’s routing semantics.When using a node port that’s not 80 (typical HTTP port), Curl sets the header for
Host
to include the port, IE:Host: books.example.com:38000
, because Envoy relies on the:authority
orHost
header to match exactly to domains, this fails routing, hence the 404.