問題:要求中的雙斜線可能會導致要求無法解析
如果要求包含兩個 (或更多) 連續斜線,可能會導致 404 錯誤。例如 /hello//world/。本範例中的問題是 hello 和 world 之間的「//」。
解決方法:篩選雙斜線
對 Istio 進入流量套用設定,篩除要求中的雙斜線並加以取代。
- 建立名為
apigee-merge-slash-filter.yaml的新設定檔。 - 將下列內容貼到檔案中:
apiVersion: networking.istio.io/v1alpha3 kind: EnvoyFilter metadata: name: apigee-merge-slashes namespace: istio-system spec: workloadSelector: labels: app: istio-ingressgateway configPatches: - applyTo: NETWORK_FILTER # http connection manager is a filter in Envoy match: context: GATEWAY listener: filterChain: filter: name: "envoy.http_connection_manager" patch: operation: MERGE value: typed_config: "@type": "type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager" merge_slashes: true - 使用下列指令套用設定:
kubectl apply -f apigee-merge-slash-filter.yaml