我正在使用帶有 minikube 的 Istio 1.10.0。Kubernetes 服務器版本為 1.19.8。
如何在http請求中添加多個標頭?是否可以放置像 request.headers["Host"] 這樣的動態值?
X-Forwarded-Host $host;
X 轉發埠 9090;X-Forwarded-Proto http;
下面的示例適用于添加回應標頭。
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
annotations:
helm.sh/hook: pre-install, pre-upgrade
creationTimestamp: "2021-11-22T13:01:36Z"
generation: 8
name: direct-vs
namespace: cvrm
resourceVersion: "72069"
selfLink: /apis/networking.istio.io/v1beta1/namespaces/cvrm/virtualservices/cvrm-direct-vs
uid: d398a13e-fd81-4ada-8e36-617287cae1bc
spec:
gateways:
- gateway.istio-system.svc.cluster.local
hosts:
- '*'
http:
- match:
- uri:
prefix: /console
route:
- destination:
host: console-bs.cvrm.svc.cluster.local
port:
number: 8087
headers:
response:
add:
Custom-Header: test
uj5u.com熱心網友回復:
您可以像處理回應一樣向請求添加標頭。
...
headers:
request:
add:
foo: bar
...
如果要添加多個標題,可以嘗試
...
headers:
request:
add:
foo: foo
bar: bar
...
無法在 Istio 清單中添加動態值。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/365793.html
標籤:Kubernetes 伊斯蒂奥
