Istio从入门到精通—— 流量治理的原理 —— VirutalService —— HTTPRedirect
流量治理的原理 —— VirutalService —— HTTPRedirect
https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPRedirect
HTTPRedirect can be used to send a 301 redirect response to the caller, where the Authority/Host and the URI in the response can be swapped with the specified values. For example, the following rule redirects requests for /v1/getProductRatings API on the ratings service to /v1/bookRatings provided by the bookratings service.
HTTPRedirect 可用于向调用方发送 301 重定向响应,其中 Authority/Host 和响应中的 URI 可与指定值交换。例如,以下规则将评级服务上的 /v1/getProductRatings API 请求重定向到 bookRatings 服务提供的 /v1/bookRatings。
apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: ratings-route spec: hosts: - ratings.prod.svc.cluster.local http: - match: - uri: exact: /v1/getProductRatings redirect: uri: /v1/bookRatings authority: newratings.default.svc.cluster.local ...
Field | Type | Description | Required |
---|---|---|---|
uri | string |
On a redirect, overwrite the Path portion of the URL with this value. Note that the entire path will be replaced, irrespective of the request URI being matched as an exact path or prefix. |
No |
authority | string |
On a redirect, overwrite the Authority/Host portion of the URL with this value. |
No |
port | uint32 (oneof) |
On a redirect, overwrite the port portion of the URL with this value. |
No |
derivePort | RedirectPortSelection (oneof) |
On a redirect, dynamically set the port:
|
No |
scheme | string |
On a redirect, overwrite the scheme portion of the URL with this value. For example, http or https. If unset, the original scheme will be used. If derivePort is set to FROM_PROTOCOL_DEFAULT, this will impact the port used as well |
No |
redirectCode | uint32 |
On a redirect, Specifies the HTTP status code to use in the redirect response. The default response code is MOVED_PERMANENTLY (301). |
No |