<p>If I write Gateway and VirtualService entries like below, what criteria do the hosts attributes match to determine whether an incoming request should be routed to the service? Is it the &quot;Host&quot; header in the HTTP request, or something else?</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: default-gateway
  namespace: web
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - example.com
    port:
      name: www
      number: 80
      protocol: HTTP
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: web
  namespace: web
spec:
  gateways:
  - default-gateway
  hosts:
  - example.com
  http:
  - route:
    - destination:
        host: webserver # assume this is the name of the Service for our deployed container
---
# Assume a Service and Deployment exist for the above Service
</code></pre>
<p>Said another way - if we ignore DNS - what &quot;Host&quot; headers could be used to access the service/deployment via the cluster/load balancer IP?</p>

<p>if you can access to the cluster using any dns, or cluster/load balancer IP, you can  change the example.com DNS to *. or other method is put all DNSs like a list in the <strong>hosts</strong> block.</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: default-gateway
  namespace: web
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - '*'
    port:
      name: www
      number: 80
      protocol: HTTP
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: web
  namespace: web
spec:
  gateways:
  - default-gateway
  hosts:
  - '*'
  http:
  - route:
    - destination:
        host: webserver # assume this is the name of the Service for our deployed container
---
# Assume a Service and Deployment exist for the above Service
</code></pre>
<p>In the case that you deploy multiple services with only one external DNS, you need to match using <strong>uri</strong> block, for example in your virtual service you can put:</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
    kind: VirtualService
    metadata:
      name: web
      namespace: web
    spec:
      gateways:
      - default-gateway
      hosts:
      - '*'
      http:
      - match:
        - uri:
            prefix: /test/service1
        rewrite:
         uri: / 
      - route:
        - destination:
            host: webserver # assume this is the name of the Service for our deployed container
</code></pre>
<p>In the example above you can access from any host header, but the criterio to match to diferentes services are the <strong>the uri block in the http match</strong></p>
<p>I hope it works for you. :)</p>
