我正在尝试为我的应用程序负载均衡器创建自定义路由规则。
我有一个正在运行的默认规则。该规则将所有内容转发到domain.com/>domain.com/links
现在我正在尝试创建另一条规则,将所有前往domain.com/links 的内容转发到外部站点......
我在“defaultService”字段中输入什么...我无法弄清楚谷歌在这里期望什么。
默认服务: 名称:匹配器1 路线规则:
在“defaultService”字段中我尝试过 域名.com www.domain.com 全局/网络服务/负载平衡/LOADBALANCERNAME
根据此文档,说明显示对于defaultService,您应该放置
global/backendServices/BACKEND\_SERVICE\_1
如果链接失败,您可以按照文档中的此 yaml 进行操作。
defaultService: global/backendServices/BACKEND_SERVICE_1
name: global-lb-map
hostRules:
- hosts:
- '*'
pathMatcher: matcher1
pathMatchers:
- defaultService: global/backendServices/BACKEND_SERVICE_1
name: matcher1
routeRules:
- matchRules:
- prefixMatch: /PREFIX
priority: PRIORITY # 0 is highest
urlRedirect:
hostRedirect: "new-host-name.com" # Omit to keep the requested host
pathRedirect: "/new-path" # Omit to keep the requested path; mutually exclusive to prefixRedirect
prefixRedirect: "/newPrefix" # Omit to keep the requested path; mutually exclusive to pathRedirect
redirectResponseCode: FOUND
stripQuery: True