首页 > 解决方案 > 特使中的重定向

问题描述

我正在我的舞台环境中测试特使配置,在这里我需要重定向到自定义页面“/oops”,只要在调用 test.com 时发生任何 5xx 错误。它可以直接访问路径“ http://test1.com/oops ”。有人可以建议我的想法吗?

static_resources:
  listeners:
  - name: test-listener
    address:
      socket_address: { address: 0.0.0.0, port_value: 30000 }

    filter_chains:
    - filters:
      - name: envoy.http_connection_manager
        config:
          access_log:
            - name: envoy.file_access_log
              config:
                path: "/dev/stdout"
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
            - name: local_service
              domains: ["test1.com"]
              routes:
              - match: { prefix: "/" }
                route: { cluster: test1_service }
            - name: local_service2
              domains: ["test2.com"]
              routes:
              - match: { prefix: "/" }
                route: { cluster: google_service }

          http_filters:
          - name: envoy.router

  clusters:
  - name: test1_service
    connect_timeout: 0.25s
    type: LOGICAL_DNS
    dns_lookup_family: V4_ONLY
    lb_policy: ROUND_ROBIN
    hosts: [{ socket_address: { address: 172.17.0.3, port_value: 80 }}]

  - name: google_service
    connect_timeout: 0.25s
    type: LOGICAL_DNS
    dns_lookup_family: V4_ONLY
    lb_policy: ROUND_ROBIN
    hosts: [{ socket_address: { address: google.com, port_value: 80 }}]

标签: dockerenvoyproxy

解决方案


您可以在 envoy 中使用HTTP 路由来完成此操作。另请参阅route.VirtualHost配置。


推荐阅读