特使中的重定向

时间:2019-09-17 09:24:29

标签: docker envoyproxy

我正在我的舞台环境中测试一个特使配置,在这里,只要在调用test.com时发生任何5xx错误,就需要重定向到自定义页面“ / oops”。可直接通过路径“ 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 }}]

1 个答案:

答案 0 :(得分:0)

您可以在特使中使用HTTP Routing来完成此任务。另请参阅route.VirtualHost配置。