【问题标题】:Identity Server4: Unable to obtain configuration from 'http://localhost:44338/.well-known/openid-configurationIdentity Server4:无法从“http://localhost:44338/.well-known/openid-configuration”获取配置
【发布时间】:2020-06-29 05:27:30
【问题描述】:

我正在使用 docker-compose 在 .Net core 3.1 中开发微服务。我们正在使用基于 Linux 的 Docker 容器。 MVC 客户端应用程序与 Identity 4 API 一起在 IIS express 中完美运行,当我在 docker-compose 中运行微服务时,客户端应用程序出现错误。

{"StatusCode":500,"Message":"内部服务器错误。"}

在 MVC 客户端容器中,我检查了容器的日志。我收到以下错误。

Unable to obtain configuration from 'http://localhost:44338/.well-known/openid-configuration'

以上 URL 代表同样在容器中运行的 Identity Server 4。 我的 docker-compose 的顺序是

version: '3.4'    
 services:     
 identity.api:
     environment:
       - ASPNETCORE_URLS=https://+:443;http://+:80
       - MvcClient=http://localhost:44353
    ports:
      - "44338:80"
      - "443"

    volumes:
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
      - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
  rinmvc:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=https://+:443;http://+:80;
      - ASPNETCORE_URLS=http://0.0.0.0:80
      - IdentityUrl=http://localhost:44338
    ports:

      - "44353:80"
      - "443"

    volumes:
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
      - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro

【问题讨论】:

  • 由于是在docker中运行,mvc客户端和Identityserver不在同一个localhost。您可能希望将 IdentityUrl 更改为 identity.api:44338
  • identity.api 要好得多,而不是与端口一起使用

标签: docker-compose containers asp.net-core-webapi identityserver4


【解决方案1】:

在这个问题上花了几天时间后,我得到了正确的解决方案。 我修改了我的 docker-compose.override 文件如下:

version: '3.4'

services:
  rabbitmq:
    ports:
      - "15672:15672"
      - "5672:5672"

  identity.api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=http://+:80
      - MvcClient=http://rinmvc  
    ports:
      - "44338:80"
    volumes:
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
      - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro

  rinmvc:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=http://+:80
      - IdentityUrl=http://identity.api
    ports:
      - "44353:80"
    volumes:
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
      - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro  

【讨论】:

    猜你喜欢
    • 2016-10-08
    • 2018-05-10
    • 1970-01-01
    • 2020-07-30
    • 2023-01-07
    • 2021-01-18
    • 2020-04-02
    • 1970-01-01
    • 2017-06-23
    相关资源
    最近更新 更多