Ras*_*wal 3 routes http-headers envoyproxy
我正在发送带有以下标头的 http 请求。
标头 = {"InstanceId" : "1"}
如何使用此标头值(即 1)路由到集群(端点)
我实际上想在 envoy.yaml 中做什么:
if (头.InstanceId == 1)
Route to cluster A
Run Code Online (Sandbox Code Playgroud)
Else If (标头.InstanceId == 2)
Route to cluster B
Run Code Online (Sandbox Code Playgroud)
有人可以帮我吗?提前致谢。
nor*_*bjd 11
如果你想根据 headers 将流量重定向到不同的集群,你可以定义以下监听器(有趣的部分是static_resources.listeners[0].filter_chains[0].filters[0].route_config.virtual_hosts[0].routes定义了两个匹配的部分):
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 8080
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
codec_type: AUTO
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: backend
domains:
- "*"
routes:
- match:
prefix: "/"
headers:
- name: "InstanceId"
exact_match: "1"
route:
cluster: clusterA
- match:
prefix: "/"
headers:
- name: "InstanceId"
exact_match: "2"
route:
cluster: clusterB
http_filters:
- name: envoy.filters.http.router
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3445 次 |
| 最近记录: |