我做了类似的事情,按照你的例子,应该是这样的:
ocelot项目中的配置:
{
"ReRoutes": [
{
"DownstreamPathTemplate": "/b/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5002
}
],
"UpstreamPathTemplate": "/b/{everything}",
"UpstreamHttpMethod": [ "Get","Post" ]
},
{
"DownstreamPathTemplate": "/c/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5003
}
],
"UpstreamPathTemplate": "/c/{everything}",
"UpstreamHttpMethod": [ "Get","Post" ]
},
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5001
}
],
"UpstreamPathTemplate": "/{everything}",
"UpstreamHttpMethod": [ "Get","Post" ]
}
],
"GlobalConfiguration": {
"BaseUrl": "https://entrypointurl.com"
}
}
参考:
https://ocelot.readthedocs.io/en/latest/introduction/gettingstarted.html
https://ocelot.readthedocs.io/en/latest/features/routing.html