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。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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 |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具