identityserver4 - 部署到反向代理后面的子路由时,IdentityServer4 发现文档返回 404
问题描述
我需要从此更改发现端点的 url:
/.well-known/openid-configuration
对此:
/identity/.well-known/openid-configuration
我正在尝试将 ID4 部署到 Azure Kubernetes 服务。当我将 ID4 部署到根地址(如http://xxxx.europe.cloudapp.azure.com)时,一切都很好 - 我看到了欢迎页面,我可以访问我的发现端点。
但是,当我将 ID4 部署到子路由(http://xxxx.europe.cloudapp.azure.com/identity)时,我无法访问 oidc 配置。我正在使用 URL 重写,因此当我单击链接以访问发现文档(http://xxxx.europe.cloudapp.azure.com/identity/.well-known/openid-configuration)时,我得到了 HTTP404。
编辑:
当我添加:
app.Use(async (context, next) =>
{
context.Request.PathBase = "/identity";
await next.Invoke();
});
所有 css/js/jpeg 文件均已正确加载。这是进步。
但是,当我单击欢迎页面上可见的链接时((http://xxxx.europe.cloudapp.azure.com/identity/.well-known/openid-configuration),我得到 HTTP404。当我单击授权时((http: //xxxx.europe.cloudapp.azure.com/identity/grants)。这是同一个故事。从链接中手动删除“/identity”仍然会导致404。
解决方案
您应该能够通过Map
在IApplicationBuilder
.
app.Map("/identity", authApp =>
{
authApp.UseIdentityServer();
});