使用ocelot和docker服务使用路由网关时出错
我正在使用ocelot创建一个Api网关,它使用NetCore中的Api服务。 ApiGateway和ApiService部署在docker上,docker由以下方式组成: Docker compose:使用ocelot和docker服务使用路由网关时出错,docker,asp.net-core,routes,api-gateway,ocelot,Docker,Asp.net Core,Routes,Api Gateway,Ocelot,我正在使用ocelot创建一个Api网关,它使用NetCore中的Api服务。 ApiGateway和ApiService部署在docker上,docker由以下方式组成: Docker compose: tresfilos.webapigateway: image: ${DOCKER_REGISTRY-}tresfilosapigateway build: context: . dockerfile: tresfilos.ApiGateway/ApiGw-Base/Dockerfil
tresfilos.webapigateway:
image: ${DOCKER_REGISTRY-}tresfilosapigateway
build:
context: .
dockerfile: tresfilos.ApiGateway/ApiGw-Base/Dockerfile
tresfilos.users.service:
image: ${DOCKER_REGISTRY-}tresfilosusersservice
build:
context: .
dockerfile: tresfilos.Users.Service/tresfilos.Users.Service/Dockerfile
tresfilos.webapigateway:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- IdentityUrl=http://identity-api
ports:
- "7000:80"
- "7001:443"
volumes:
- ./tresfilos.ApiGateway/Web.Bff:/app/configuration
tresfilos.users.service:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
ports:
- "7002:80"
- "7003:443"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
Docker compose.override:
tresfilos.webapigateway:
image: ${DOCKER_REGISTRY-}tresfilosapigateway
build:
context: .
dockerfile: tresfilos.ApiGateway/ApiGw-Base/Dockerfile
tresfilos.users.service:
image: ${DOCKER_REGISTRY-}tresfilosusersservice
build:
context: .
dockerfile: tresfilos.Users.Service/tresfilos.Users.Service/Dockerfile
tresfilos.webapigateway:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- IdentityUrl=http://identity-api
ports:
- "7000:80"
- "7001:443"
volumes:
- ./tresfilos.ApiGateway/Web.Bff:/app/configuration
tresfilos.users.service:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
ports:
- "7002:80"
- "7003:443"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
在配置中我定义了.json如下:
"ReRoutes": [
{
"DownstreamPathTemplate": "/api/{version}/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "tresfilos.users.service",
"Port": 7002
}
],
"UpstreamPathTemplate": "/api/{version}/user/{everything}",
"UpstreamHttpMethod": [ "POST", "PUT", "GET" ]
},
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost:7001"
}
当我从url使用ApiGateway时:
http://localhost:7000/api/v1/user/Login/authentication
我在terminal docker中有错误:
为什么会出现上述错误以及如何修复它?您正在运行哪个版本的Ocelot 我发现另一个线程有类似的外观问题,显然从16.0.0版本的Ocelot“ReRoutes”在Ocelot配置文件中被更改为“Routes” 我找到的线程是-我用以下方法修复它:
(谢谢JasonS).16.0.1版,当更改为Routes时会生成错误更改为Routes后会出现什么错误?System.AggregateException:'发生一个或多个错误。(无法启动Ocelot,错误为:身份验证选项AuthenticationProviderKey:IdentityApiKey,AllowedScopes:[]是不受支持的身份验证提供程序)'