ServiceEntry with multiple dns endpoints and HOST header

Hi everyone,

My team have trouble with Egress Gateway routing to external service backed up by multiple endpoints.

For example we have(simple main config attributes):
kind: ServiceEntry
spec:
endpoints:
- address: some.address1
ports:
http: 2222
- address: some.address2
ports:
http: 1111
hosts:
- synthetic.address
location: MESH_EXTERNAL
resolution: DNS
ports:
- name: http
number: 80
protocol: HTTP

so when our Virtual Service is being called, it setting destination to
synthetic.address

route:

  • destination:
    host: synthetic.address
    port:
    number: 80

and all out request that passed this virtual service is balanced between ServiceEntry endpoints.

BUT endpoints looking at HOST header and expecting it to be SAME as DNS name (some.address1, some.address2 accordingly)

are there any way to do that in istio? (its looking like we need some option for ServiceEntry to rewrite HOST header according to endpoint)

1 Like

I was recently struggling with the same issue, and found a way to set the Host header to the actual destination endpoint.

We should define an EnvoyFilter which adds auto_host_rewrite: true config to
the HTTP_ROUTE for synthetic.address.

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: auto-header-rewrite
spec:
  configPatches:
  - applyTo: HTTP_ROUTE
    match:
      routeConfiguration:
        vhost:
          name: synthetic.address:80
          route:
            action: ANY
    patch:
      operation: MERGE
      value:
        route:
          auto_host_rewrite: true