应用程序负载均衡器自定义路由规则 YAML 格式

问题描述 投票:0回答:1

我正在尝试为我的应用程序负载均衡器创建自定义路由规则。

我有一个正在运行的默认规则。该规则将所有内容转发到domain.com/>domain.com/links

现在我正在尝试创建另一条规则,将所有前往domain.com/links 的内容转发到外部站点......

我在“defaultService”字段中输入什么...我无法弄清楚谷歌在这里期望什么。

默认服务: 名称:匹配器1 路线规则:

  • 比赛规则:
    • 前缀匹配:/links 优先级:1 网址重定向: 主机重定向:extdomain.com 路径重定向:/URL 重定向响应代码:找到, stripQuery: True

在“defaultService”字段中我尝试过 域名.com www.domain.com 全局/网络服务/负载平衡/LOADBALANCERNAME

google-cloud-platform google-cloud-load-balancer
1个回答
0
投票

根据此文档,说明显示对于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

© www.soinside.com 2019 - 2024. All rights reserved.