如何在AddHealthCheckendPoint()方法中添加带有身份验证的URL

发布于 2025-02-08 07:30:23 字数 2321 浏览 1 评论 0原文

我有一个大型网站, www.example.com ,在IIS上托管了Windows Authentication On打开的IIS。该站点成功加载,并索要预期的身份验证详细信息。当我加载 www.example.com/healthchecks-ui 时,问题就到了。 由于UI页面使用 www.example.com/health 端点,它是身份验证墙后面的端点,页面加载具有不健康状态,如下所示:

”“在此处输入图像说明”

当我关闭身份验证并允许在iis上允许匿名连接 www.example.com/healthchecks-ui 页面按预期加载:

“在此处输入图像说明”

这就是我在startup.cs文件中设置HealthCheck-ui设置的方式:

            services.AddHealthChecksUI(opt =>
            {
                opt.UseApiEndpointHttpMessageHandler(sp =>
                {
                    return new HttpClientHandler
                    {
                        ClientCertificateOptions = ClientCertificateOption.Manual,
                        ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => { return true; }
                    };
                });
                opt.SetEvaluationTimeInSeconds(5); //time in seconds between check    
                opt.MaximumHistoryEntriesPerEndpoint(60); //maximum history of checks    
                opt.SetApiMaxActiveRequests(1); //api requests concurrency    
                opt.AddHealthCheckEndpoint("Site Health", "www.example.com/health"); //map health check api    
            }).AddInMemoryStorage();
        }

是否

                endpoints.MapHealthChecks("/health", new HealthCheckOptions()
                {
                    Predicate = _ => true,
                    ResponseWriter = UIResponseWriter.
                    WriteHealthCheckUIResponse
                });
                endpoints.MapHealthChecksUI();

可以通过添加一些要使用的静态凭证来考虑身份验证?任何建议将不胜感激。

I have a blazor website, www.example.com, hosted on IIS with windows authentication turned on. The site loads successfully and asks for authentication details as expected. The problem comes when I load the www.example.com/healthchecks-ui page.
Since the UI page uses the www.example.com/health endpoint which is behind an authentication wall, the page loads with an unhealthy status as shown below:

enter image description here

When I turn off authentication and allow for anonymous connections on IIS the www.example.com/healthchecks-ui page loads as expected:

enter image description here

This is how i set the healthcheck-ui settings in the startup.cs file:

            services.AddHealthChecksUI(opt =>
            {
                opt.UseApiEndpointHttpMessageHandler(sp =>
                {
                    return new HttpClientHandler
                    {
                        ClientCertificateOptions = ClientCertificateOption.Manual,
                        ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => { return true; }
                    };
                });
                opt.SetEvaluationTimeInSeconds(5); //time in seconds between check    
                opt.MaximumHistoryEntriesPerEndpoint(60); //maximum history of checks    
                opt.SetApiMaxActiveRequests(1); //api requests concurrency    
                opt.AddHealthCheckEndpoint("Site Health", "www.example.com/health"); //map health check api    
            }).AddInMemoryStorage();
        }

and

                endpoints.MapHealthChecks("/health", new HealthCheckOptions()
                {
                    Predicate = _ => true,
                    ResponseWriter = UIResponseWriter.
                    WriteHealthCheckUIResponse
                });
                endpoints.MapHealthChecksUI();

Is there a way to account for authentication by adding some static credentials to be used? Any suggestions would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文