HTTP在使用Docker Container的Service Fabric中不起作用

问题描述 投票:3回答:1

我正在开发一个自托管的.Net Core Rest API,它将托管在Service Fabric中的Docker Container中。我无法在Service Fabric中配置SSL / Https。 Http似乎有效。我使用HttpSys作为Web服务器,而不是Kestrel,因为我读过它不建议选择没有反向代理(如IIS)的服务。

这是Web服务器代码段。

return WebHost.CreateDefaultBuilder(args)
            .UseApplicationInsights()
                .UseStartup<Startup>()
                .UseHttpSys(
                    options =>
                    {
                        options.Authentication.Schemes = AspNetCore.Server.HttpSys.AuthenticationSchemes.None;
                        options.Authentication.AllowAnonymous = true;
                    }
                )                  
                .Build();

这是ServiceManifest.xml Endpoints片段。

<Endpoints>      
  <Endpoint Name="ServiceEndpoint" Protocol="http" Port="80" />
  <Endpoint Name="ServiceEndpointHttps" Protocol="https" Port="443" Type="Input" CertificateRef="SSLCertificate" />
</Endpoints>

这是ApplicationManifest EnvironmentVariable片段。

<EnvironmentVariable Name="ASPNETCORE_URLS" Value="https://*:443/;http://*:80/"/>

这是ApplicationManifest.xml策略片段。

<Policies>
  <ContainerHostPolicies CodePackageRef="Code">
    <RepositoryCredentials AccountName="accountname" Password="password" PasswordEncrypted="false" />
    <PortBinding ContainerPort="80" EndpointRef="ServiceEndpoint"/>
    <PortBinding ContainerPort="443" EndpointRef="ServiceEndpointHttps"/> 
  </ContainerHostPolicies>
  <EndpointBindingPolicy CertificateRef="SSLCertificate" EndpointRef="ServiceEndpointHttps" />
</Policies>

这是ApplicationManifest.xml证书片段。

<Certificates>
<EndpointCertificate Name="SSLCertificate" X509FindValue="cert thumbprint"/>
</Certificates>

最初,当我在CurrentUser \ My Certificate Store中获得SSL证书时,我遇到了证书部署问题。我在LocalMachine \ My Certificate Store中部署证书后解决了这个问题。通过此修复,Service似乎仅在端口80中使用HTTP协议,而不在端口443中使用HTTPS协议。

Service Fabric Explorer也不会在“事件日志”中显示任何错误和错误。我在Local Service Fabric和Azure Service Fabric实例中都遇到此问题。

任何关于此的想法/指示将不胜感激。

docker ssl https .net-core azure-service-fabric
1个回答
0
投票

使用Service Fabric for container和https可以遵循这个doc

它会将证书作为环境变量注入容器中。

但对于Linux集群,存在一个问题。 Certificates_ServicePackageName_CodePackageName_CertName_PEM和Certificates_ServicePackageName_CodePackageName_CertName_PrivateKey表示的文件具有完全相同的内容。

我正在等待Azure中国支持者对此进一步澄清,不确定这是否是中国特有的问题。

© www.soinside.com 2019 - 2024. All rights reserved.