AspNetCore.Proxy 重用连接错误消息

发布于 2025-01-11 05:37:46 字数 2400 浏览 0 评论 0原文

我使用 AspNetCore.Proxy 向 SSRS(报告服务)应用程序提供请求

->代理(应用程序内部)-> SSRS

该应用程序可从外部网络访问。 SSRS 只能从内部网络 (HTTP) 访问。

当应用程序在 HTTP (80) 上发布时,不会发生任何问题或错误。 但是,当应用程序在 HTTPS (443) 上发布时,会发生重用连接错误。 SSRS 在 HTTP 上使用自己的内部门户网站 (80)

请求无法被代理。 由于无法重用连接,身份验证失败。

那么,如何解决这个错误呢?

应用程序代理配置:

            app.UseProxies(proxies =>
            {
                var url = (string)null;
                proxies.Map(
                    "ReportServer.aspx",
                    proxy => proxy.UseHttp((context, args) =>
                    {
                        url = $"{_reportSettings.SSRSReportServerBaseUrl}/ReportServer/Pages/ReportViewer.aspx" + context.Request.QueryString;
                        _logger.WriteWithCallerName(LogLevel.Debug, "Startup::Proxy", url);
                        return url;
                    },
                    builder => builder.WithHttpClientName(HTTP_CLIENT_NAME))
                    );
                proxies.Map(
                    _reportSettings.SSRSProxyRouteBase,
                    proxy => proxy.UseHttp((context, args) =>
                    {
                        url = $"{_reportSettings.SSRSReportServerBaseUrl}/ReportServer/Pages/ReportViewer.aspx" + context.Request.QueryString;
                        _logger.WriteWithCallerName(LogLevel.Debug, "Startup::Proxy", url);
                        return url;
                    },
                    builder => builder.WithHttpClientName(HTTP_CLIENT_NAME))
                    );
                proxies.Map(
                    _reportSettings.SSRSProxyRouteBase + "/{**rest}",
                    proxy => proxy.UseHttp((context, args) =>
                    {
                        url = $"{_reportSettings.SSRSReportServerBaseUrl}/ReportServer/" + args["rest"] + context.Request.QueryString;
                        _logger.WriteWithCallerName(LogLevel.Debug, "Startup::Proxy", url);
                        return url;
                    },
                    builder => builder.WithHttpClientName(HTTP_CLIENT_NAME))
                    );

            });

来自设置的参数:

    "SSRSReportServerBaseUrl": "http://172.16.1.40",
    "SSRSProxyRouteBase": "ReportServer",

I use AspNetCore.Proxy to serve request to SSRS (reports service)

Application -> Proxy (inside application) -> SSRS

The application is accessible from an external network.
SSRS is accessible only from an internal network (HTTP)

When the application is published on HTTP (80) no issues or errors happen.
But, when the application is published on HTTPS (443) - a reuse connection error occurs.
SSRS uses its own internal web portal on HTTP (80)

Request could not be proxied.
Authentication failed because the connection could not be reused.

So, how to resolve this error?

Application proxy config:

            app.UseProxies(proxies =>
            {
                var url = (string)null;
                proxies.Map(
                    "ReportServer.aspx",
                    proxy => proxy.UseHttp((context, args) =>
                    {
                        url = 
quot;{_reportSettings.SSRSReportServerBaseUrl}/ReportServer/Pages/ReportViewer.aspx" + context.Request.QueryString;
                        _logger.WriteWithCallerName(LogLevel.Debug, "Startup::Proxy", url);
                        return url;
                    },
                    builder => builder.WithHttpClientName(HTTP_CLIENT_NAME))
                    );
                proxies.Map(
                    _reportSettings.SSRSProxyRouteBase,
                    proxy => proxy.UseHttp((context, args) =>
                    {
                        url = 
quot;{_reportSettings.SSRSReportServerBaseUrl}/ReportServer/Pages/ReportViewer.aspx" + context.Request.QueryString;
                        _logger.WriteWithCallerName(LogLevel.Debug, "Startup::Proxy", url);
                        return url;
                    },
                    builder => builder.WithHttpClientName(HTTP_CLIENT_NAME))
                    );
                proxies.Map(
                    _reportSettings.SSRSProxyRouteBase + "/{**rest}",
                    proxy => proxy.UseHttp((context, args) =>
                    {
                        url = 
quot;{_reportSettings.SSRSReportServerBaseUrl}/ReportServer/" + args["rest"] + context.Request.QueryString;
                        _logger.WriteWithCallerName(LogLevel.Debug, "Startup::Proxy", url);
                        return url;
                    },
                    builder => builder.WithHttpClientName(HTTP_CLIENT_NAME))
                    );

            });

Parameters from settings:

    "SSRSReportServerBaseUrl": "http://172.16.1.40",
    "SSRSProxyRouteBase": "ReportServer",

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

因为看清所以看轻 2025-01-18 05:37:46

最后我有了可行的解决方案。
详细信息请参见 proxy lib github 页面

重用连接问题

Finally I had have works solution.
Details described at proxy lib github page

Reuse connection issue

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文