首页 > 解决方案 > 已部署的 Blazor 客户端尝试访问 OIDC 的 Localhost .well-known/openid-configuration

问题描述

我已经在 Ubuntu 机器上部署了一个开箱即用的app.UseHttpsRedirection();.NET 5.0 Blazor WebAssembly 应用程序(注释掉的除外)和个人帐户dotnet publish --configuration Release

appsettings.json 是这样配置的

{
  "ConnectionStrings": {
    "DefaultConnection": "Data Source=machine's ip;Initial Catalog=db;User Id=username;Password=password"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
"IdentityServer": {
    "Clients": {
      "WebApplication.Client": {
        "Profile": "IdentityServerSPA"
      }
    },
    "Key": {
      "Type": "File",
      "FilePath": "../certificate.pfx",
      "Password": "password",
      "Name": "/CN=name"
    }
  },
  "Kestrel": {
    "Certificates": {
      "Default": {
        "Path": "../certificate.pfx",
        "Password": "password"
      }
    }
  },
  "AllowedHosts": "*"
}

apache2.conf 是这样配置的

...
<Location /test>
    ProxyPass  http://localhost:5000
    ProxyPassReverse  http://localhost:5000
    ProxyHTMLURLMap http://localhost:5000
    ProxyHTMLURLMap / /test/ 
</Location>
...

当我按预期通过 http://localhost:5000 在本地访问它时,它工作正常。当我尝试从网络通过 http:// machine's_ip /test 访问它时,页面按预期加载并正常运行,除了通过 GET http://localhost:5000/.well-known/ 进行的身份验证openid 配置网络::ERR_CONNECTION_REFUSED。

如何让 Blazor 客户端从机器的 IP 而不是不存在的 localhost 获取 OIDC?

标签: blazor

解决方案


推荐阅读