When a VirtualService routes traffic from one service to another, the destination service may reject the request if the Host or Authority header still contains the original hostname. Service Mesh (ASM) lets the sidecar proxy rewrite these headers to match the destination before forwarding the request, so the destination service accepts it.
How it works
With host rewriting enabled, the request flow works as follows:
The sleep pod sends a request to
nginx:8000/headers.The VirtualService matches the request and applies the rewrite rule, changing the
Authorityheader tohttpbin:8000.The sidecar proxy forwards the request to the HTTPBin service instead of NGINX.
HTTPBin receives the request with the rewritten
Hostheader (httpbin:8000) and returns the headers in its response.
Prerequisites
Before you begin, make sure that you have:
Completed the preparations described in Preparations
Deployed the HTTPBin, sleep, and NGINX services in the mesh
Create the rewrite rule
-
Log on to the ASM console. In the left-side navigation pane, choose .
-
On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose . On the page that appears, click Create.
On the Mesh Management page, click the name of the target ASM instance.
In the left-side navigation pane, choose Traffic Management Center > VirtualService, then click Create.
On the Create page, configure the parameters as shown in the following screenshot, then click Preview.

The following code shows the YAML file for preview:
apiVersion: networking.istio.io/v1beta1 kind: VirtualService metadata: name: nginx namespace: default spec: hosts: - nginx.default.svc.cluster.local http: - rewrite: authority: 'httpbin:8000' route: - destination: host: httpbin.default.svc.cluster.localConfirm that the YAML content is correct, click Submit, then click Create.
Verify the configuration
After you create the VirtualService, confirm that host rewriting takes effect.
Connect to the Container Service for Kubernetes (ACK) cluster with kubectl, then run the following command:
kubectl exec -it deploy/sleep -- curl nginx:8000/headersCheck the output. If the rewrite rule is working, the
Hostheader showshttpbin:8000instead of the original NGINX hostname:{ "headers": { "Accept": "*/*", "Host": "httpbin:8000", "User-Agent": "curl/8.1.2" } }This output confirms two things:
The request from the sleep pod to
nginx:8000/headerswas forwarded to the HTTPBin service's/headersendpoint.The
Hostheader was rewritten from the NGINX hostname tohttpbin:8000.