[英]how to expose functionality from reverseproxy service
我有一個反向代理服務,並且我使用SharpReverseProxy處理所有傳入請求:
為了配置服務, Startup
類中包含以下代碼:
public void Configure(IApplicationBuilder app,
IHostingEnvironment env,
ILoggerFactory loggerFactory) {
app.UseProxy(new List<ProxyRule> {
new ProxyRule {
Matcher = uri => uri.AbsoluteUri.Contains("/api/"),
Modifier = (req, user) => {
var match = Regex.Match(req.RequestUri.AbsolutePath, "/api/(.+)service");
req.RequestUri = new Uri(string.Format("http://{0}.{1}/{2}",
match.Groups[1].Value,
req.RequestUri.Host,
req.RequestUri.AbsolutePath.Replace(match.Value, "/api/")
));
},
RequiresAuthentication = true
}
},
r => {
_logger.LogDebug($"Proxy: {r.ProxyStatus} Url: {r.OriginalUri} Time: {r.Elapsed}");
if (r.ProxyStatus == ProxyStatus.Proxied) {
_logger.LogDebug($" New Url: {r.ProxiedUri.AbsoluteUri} Status: {r.HttpStatusCode}");
}
});
}
如何以一種可以在外部對其進行https訪問的方式公開此服務?
我知道我們可以使用FabricTransportServiceRemotingListener
添加偵聽器, FabricTransportServiceRemotingListener
所示:
new ServiceInstanceListener(serviceContext => new FabricTransportServiceRemotingListener(serviceContext,
new MyService(),
new FabricTransportRemotingListenerSettings
{
EndpointResourceName = "MyServiceEndpoint"
}), "MyServiceEndpoint"),
我的問題是,我不明白應該用MyService()
替換什么,因為頂部的ReverseProxy代碼沒有服務。
如何將反向代理配置公開為服務,從而能夠通過FabricTransportRemotingListenerSettings
公開它?
你不能 SF遠程處理是特定於平台的通信機制。 另外,也不應從群集外部使用它。
您可以公開HttpSysCommunicationListener
以將代理公開為可靠服務的HTTP端點 。
確保按照所述將端點配置為HTTPS。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.