我有一个入口为/api/my-service
的服务
我的金刚配置是这样的:
services:
- name: myService
protocol: http
host: myservice.mynamespace
port: 8080
path: /
plugins:
- name: jwt
config:
key_claim_name: iss
claims_to_verify:
- exp
routes:
- tags:
- OAS3_import
- OAS3file_openapi.json
name: myservice-backend
methods:
- GET
paths:
- /api/my-service/v0/contexts
strip_path: false
- tags:
当我请求http://kongProxy/api/my-service/v0/myEndpoint
时,我希望kong创建一个类似http://my-service/v0/myEndpoint
的上游请求
我想我可以使用strip_path设置,但这会去掉后缀,而不是前缀。
我看了一下请求转换器,但看起来像是一个矫枉过正的东西。我更喜欢避免它,因为cong图像已经提供给我,并希望避免不得不请求修改。
有什么想法吗?
1条答案
按热度按时间az31mfrm1#
我想你可以用正则表达式匹配来实现这个功能。如果你创建了一个匹配前缀 * 的正则表达式组,那么strip路径将删除不匹配的后缀。对不起,我现在还不能测试这个。
https://docs.konghq.com/gateway/latest/how-kong-works/routing-traffic/#using-regex-in-paths