[英]How to configure and enable Azure Service Fabric Reverse Proxy for an existing on-premises cluster?
Is the Azure Service Fabric Reverse Proxy available in an on-premises cluster? Azure服务结构反向代理是否可在内部部署群集中使用? If so, how can I enable it for an existing cluster? 如果是这样,我如何为现有群集启用它?
The Service Fabric Reverse Proxy is described here . 此处描述了 Service Fabric Reverse Proxy。 It allows clients external to the cluster to access application services by name with a special URL, without needing to know the exact host:port on which an instance of the service is running (which may change as services are automatically moved around). 它允许群集外部的客户端通过名称使用特殊URL访问应用程序服务,而无需知道运行服务实例的确切主机:端口(可能会随着服务自动移动而更改)。
By default the Service Fabric Reverse Proxy does not appear to be enabled for my on-prem cluster with two instances of a stateless service. 默认情况下,似乎没有为具有两个无状态服务实例的本地群集启用Service Fabric反向代理。 I tried using the documented port 19008 but could not reach the service using the recommended URI syntax. 我尝试使用记录的端口19008,但无法使用推荐的URI语法访问该服务。
To wit, this works: 即,这工作:
http://fqdn:20001/api/odata/v1/$metadata
but this does not: 但这不是:
http://fqdn:19008/MyApp/MyService/api/odata/v1/$metadata
In the NodeTypes section of the ClusterConfig JSON used to set up my on-prem cluster, there is a property "httpGatewayEndpointPort": "19080", but that port does not appear to work as a reverse proxy (it is the Service Fabric Explorer web-app endpoint). 在用于设置我的本地群集的ClusterConfig JSON的NodeTypes部分中,有一个属性“httpGatewayEndpointPort”:“19080”,但该端口似乎不能用作反向代理(它是Service Fabric Explorer Web -app endpoint)。 I am guessing that the needed configuration is specified somehow in the cluster config JSON. 我猜测在集群配置JSON中以某种方式指定了所需的配置。 There are instructions in the referenced article that explain how to configure the reverse proxy in the cloud, but not on-premises. 参考文章中有说明解释了如何在云中配置反向代理,但不在本地配置。
What I am looking for are instructions on how to set up the Service Fabric reverse proxy in an on-premises multi-machine cluster or dev cluster. 我正在寻找的是有关如何在本地多机群集或开发群集中设置Service Fabric反向代理的说明。
Yes, the reverse proxy is available on-premises. 是的,反向代理可在本地使用。
To get it working for an existing cluster, it must be configured and enabled in the cluster config XML and then the new config must be deployed, as described below. 要使其适用于现有群集,必须在群集配置XML中对其进行配置和启用,然后必须部署新配置,如下所述。
For a new cluster, set it up in the cluster config JSON before creating the cluster, as described by @Scott Weldon. 对于新群集,请在创建群集之前在群集配置JSON中进行设置,如@Scott Weldon所述。
@Senj provided the clue (thanks!) that led me to the answer. @Senj提供了线索(谢谢!),这让我得到答案。 I had recently updated my Service Fabric bits on my dev box to 5.1.163.9590. 我最近在我的开发盒上更新了我的Service Fabric位到5.1.163.9590。 When I looked in C:\\SfDevCluster\\Data\\FabricHostSettings.xml, I noticed the following: 当我查看C:\\ SfDevCluster \\ Data \\ FabricHostSettings.xml时,我注意到以下内容:
<Section Name="FabricNode">
...
<Parameter Name="NodeVersion" Value="5.1.163.9590:1.0:0" />
...
<Parameter Name="HttpApplicationGatewayListenAddress" Value="19081" />
<Parameter Name="HttpApplicationGatewayProtocol" Value="http" />
...
</Section>
Interesting! 有趣! With the dev cluster fired up, I browsed to: 随着开发群集的启动,我浏览了:
http://localhost:19081/MyApp/MyService/api/odata/v1/$metadata
and voila! 瞧! My API returned the expected data. 我的API返回了预期的数据。 So @Senj was correct that it has to do with the HttpApplicationGateway settings. 所以@Senj是正确的,它与HttpApplicationGateway设置有关。 I am guessing that in the latest SDK version it is pre-configured and enabled by default. 我猜测在最新的SDK版本中,它是预先配置并默认启用的。 (What threw me off is all the docs refer to port 19008, but the actual configured port was 19081!) (让我失望的是所有文档都引用了端口19008,但实际配置的端口是19081!)
In order to get the reverse proxy to work on the 'real' multi-machine (VM) cluster, I did the following (Note: I don't think upgrading the cluster codepackage was necessary, but since I had nothing in my image store for the cluster upgrade, and the cluster upgrade process requires a code package, I used the latest version): 为了让反向代理在“真正的”多机(VM)集群上工作,我做了以下(注意:我不认为升级集群代码包是必要的,但因为我的图像存储中没有任何内容对于集群升级,集群升级过程需要代码包,我使用的是最新版本):
To the NodeType Endpoints section, add: 在NodeType端点部分,添加:
<NodeTypes>
<NodeType Name="NodeType0">
<Endpoints>
<HttpApplicationGatewayEndpoint Port="19081" Protocol="http" />
...
</Endpoints>
</NodeType>
</NodeTypes>
and under <FabricSettings>
, add the following section: 在<FabricSettings>
,添加以下部分:
<Section Name="ApplicationGateway/Http">
<Parameter Name="IsEnabled" Value="true" />
</Section>
Using Service Fabric PowerShell commands: 使用Service Fabric PowerShell命令:
After the cluster upgrade was complete, I was able to query my service API using the reverse proxy endpoint and appname/servicename URL syntax: 集群升级完成后,我可以使用反向代理端点和appname / servicename URL语法查询我的服务API:
http://fqdn:19081/MyApp/MyService/api/odata/v1/$metadata
I enabled this in the standalone installer version (5.1.156) by adding the following line to the JSON configuration file under the nodeTypes
element (I used ClusterConfig.Unsecure.MultiMachine.json
but I assume any of the JSON files would work): 我在独立安装程序版本(5.1.156)中通过将以下行添加到nodeTypes
元素下的JSON配置文件中来启用此功能(我使用了ClusterConfig.Unsecure.MultiMachine.json
但我假设任何JSON文件都可以工作):
"httpApplicationGatewayEndpointPort": "19081"
So the final nodeTypes
looked like this: 所以最终的nodeTypes
看起来像这样:
"nodeTypes": [
{
"name": "NodeType0",
"clientConnectionEndpointPort": "19000",
"clusterConnectionEndpoint": "19001",
"httpGatewayEndpointPort": "19080",
"httpApplicationGatewayEndpointPort": "19081",
"applicationPorts": {
"startPort": "20001",
"endPort": "20031"
},
"ephemeralPorts": {
"startPort": "20032",
"endPort": "20062"
},
"isPrimary": true
}
]
I think it has something to do with the HttpApplicationGatewayEndpoint property, see also my question on https://github.com/Azure/service-fabric-issues/issues/5 But it doesn't work for me.. 我认为它与HttpApplicationGatewayEndpoint属性有关,另请参阅https://github.com/Azure/service-fabric-issues/issues/5上的问题但是它对我不起作用..
Also notice that 还要注意
<Section Name="ApplicationGateway/Http">
<Parameter Name="IsEnabled" Value="true" />
</Section>
is true for me. 对我来说是对的。
Edit: 编辑:
I noticed that on my Windows-Only installation, HttpApplicationGatewayListenAddress has value 0 in the FabricHostSettings.xml 我注意到在我的Windows-Only安装中,HttpApplicationGatewayListenAddress在FabricHostSettings.xml中的值为0
<Parameter Name="HttpGatewayListenAddress" Value="19080" />
<Parameter Name="HttpGatewayProtocol" Value="http" />
<Parameter Name="HttpApplicationGatewayListenAddress" Value="0" />
<Parameter Name="HttpApplicationGatewayProtocol" Value="" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.