从请求中移除双斜杠
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
问题:请求中的双斜杠会导致请求无法解析
包含两个(或更多)连续斜杠的请求可能会导致 404 错误。例如 /hello//world/
。此示例中的问题是 hello
和 world
之间的“//
”。
解决方案:过滤双斜杠
将配置应用于 Istio Ingress,以过滤请求中的双斜杠,并替换它们。
- 创建名为
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
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-05-21。
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"Hard to understand"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"Incorrect information or sample code"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"Missing the information/samples I need"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻译问题"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"易于理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"解决了我的问题"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]