return WebHost.CreateDefaultBuilder(args)
//.UseUrls("https://*:5001")
.UseStartup<Startup>()
.ConfigureKestrel(options =>
{
options.Listen(IPAddress.Loopback, 5001, listenOptions =>
{
listenOptions.UseHttps("server.pfx", "linezero");
});
})
.Build();
FROM mcr.microsoft.com/dotnet/core/runtime:2.2 AS base
WORKDIR /safety_experience_hall
EXPOSE 5001
FROM base AS final
WORKDIR /safety_experience_hall
COPY . /safety_experience_hall
ENV ASPNETCORE_ENVIRONMENT Production
ENTRYPOINT ["dotnet", "Qianbian.SafetyExperienceHall.Web.Host.dll"]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5c04e916d71d safety_experience_hall:v7 "dotnet Qianbian.Saf…" 13 seconds ago Up 12 seconds 0.0.0.0:9595->5001/tcp goofy_snyder
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using '/root/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
Creating key {dba781f4-67f0-45ec-b28f-c0619369ee8b} with creation date 2019-08-15 03:52:58Z, activation date 2019-08-15 03:52:58Z, and expiration date 2019-11-13 03:52:58Z.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {dba781f4-67f0-45ec-b28f-c0619369ee8b} may be persisted to storage in unencrypted form.
info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]
Writing data to file '/root/.aspnet/DataProtection-Keys/key-dba781f4-67f0-45ec-b28f-c0619369ee8b.xml'.
warn: Microsoft.AspNetCore.Server.Kestrel[0]
Overriding address(es) 'http://+:80'. Binding to endpoints defined in UseKestrel() instead.
Hosting environment: Production
Content root path: /safety_experience_hall
Now listening on: https://127.0.0.1:5001
Application started. Press Ctrl+C to shut down.
你访问的IP错了,不是127.0.0.1,应该是192.168.99.100:9595
这不挺好的么,没问题呀。
大佬,我访问
https://127.0.0.1:5001
直接就是拒绝访问了。不知道还要配置啥,
9595
这个端口也访问不了
@骑着蚊子去太阳: 是拒绝访问,还是端口不通?
@czd890:
127.0.0.1 已拒绝连接。ERR_CONNECTION_REFUSED
,然后telnet 127.0.0.1 5001,连接失败127.0.0.1 未发送任何数据。ERR_EMPTY_RESPONSE
,然后telnet 127.0.0.1 9595,能通TCP 0.0.0.0:9595 0.0.0.0:0 LISTENING 15640
TCP 127.0.0.1:9595 127.0.0.1:61197 TIME_WAIT 0
TCP [::]:9595 [::]:0 LISTENING 15640
@czd890: 不整成https是可以的
@骑着蚊子去太阳:
127.0.0.1:5001 是你docker container的地址 端口不通是对的
127.0.0.1:9595 是你host主机的地址。端口通是对的
程序 log级别设置到trace,看看日志
你可以想在本机以console run 起来你的程序,看看走https是不是ok,在放到docker里面是不是ok
@czd890: 大佬,本地测试可以的,发布到docker没有啥日志输出啊。
@czd890: 大佬,我真看不出来。
dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[3]
Hosting starting
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using '/root/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.DefaultKeyResolver[53]
Repository contains no viable default key. Caller should generate a key with immediate activation.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider[57]
Policy resolution states that a new key should be added to the key ring.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
Creating key {8deab1a7-af73-43bc-93f5-5712ffa4e1c3} with creation date 2019-08-15 10:38:48Z, activation date 2019-08-15 10:38:48Z, and expiration date 2019-11-13 10:38:48Z.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[32]
Descriptor deserializer type for key {8deab1a7-af73-43bc-93f5-5712ffa4e1c3} is 'Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[34]
No key escrow sink found. Not writing key {8deab1a7-af73-43bc-93f5-5712ffa4e1c3} to escrow.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {8deab1a7-af73-43bc-93f5-5712ffa4e1c3} may be persisted to storage in unencrypted form.
info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]
Writing data to file '/root/.aspnet/DataProtection-Keys/key-8deab1a7-af73-43bc-93f5-5712ffa4e1c3.xml'.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[23]
Key cache expiration token triggered by 'CreateNewKey' operation.
dbug: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[37]
Reading data from file '/root/.aspnet/DataProtection-Keys/key-8deab1a7-af73-43bc-93f5-5712ffa4e1c3.xml'.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[18]
Found key {8deab1a7-af73-43bc-93f5-5712ffa4e1c3}.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.DefaultKeyResolver[13]
Considering key {8deab1a7-af73-43bc-93f5-5712ffa4e1c3} with expiration date 2019-11-13 10:38:48Z as default key.
dbug: Microsoft.AspNetCore.DataProtection.TypeForwardingActivator[0]
Forwarded activator type request from Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 to Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Culture=neutral, PublicKeyToken=adb9793829ddae60
dbug: Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ManagedAuthenticatedEncryptorFactory[11]
Using managed symmetric algorithm 'System.Security.Cryptography.Aes'.
dbug: Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ManagedAuthenticatedEncryptorFactory[10]
Using managed keyed hash algorithm 'System.Security.Cryptography.HMACSHA256'.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider[2]
Using key {8deab1a7-af73-43bc-93f5-5712ffa4e1c3} as the default key.
dbug: Microsoft.AspNetCore.DataProtection.Internal.DataProtectionStartupFilter[0]
Key ring with default key {8deab1a7-af73-43bc-93f5-5712ffa4e1c3} was loaded during application startup.
dbug: Microsoft.AspNetCore.Mvc.MvcJsonOptions[0]
Compatibility switch AllowInputFormatterExceptionMessages in type MvcJsonOptions is using compatibility value True for version Version_2_2
dbug: Microsoft.AspNetCore.Mvc.MvcOptions[0]
Compatibility switch AllowCombiningAuthorizeFilters in type MvcOptions is using compatibility value True for version Version_2_2
dbug: Microsoft.AspNetCore.Mvc.MvcOptions[0]
Compatibility switch AllowBindingHeaderValuesToNonStringModelTypes in type MvcOptions is using compatibility value True for version Version_2_2
dbug: Microsoft.AspNetCore.Mvc.MvcOptions[0]
Compatibility switch AllowValidatingTopLevelNodes in type MvcOptions is using compatibility value True for version Version_2_2
dbug: Microsoft.AspNetCore.Mvc.MvcOptions[0]
Compatibility switch InputFormatterExceptionPolicy in type MvcOptions is using compatibility value MalformedInputExceptions for version Version_2_2
dbug: Microsoft.AspNetCore.Mvc.MvcOptions[0]
Compatibility switch SuppressBindingUndefinedValueToEnumType in type MvcOptions is using compatibility value True for version Version_2_2
dbug: Microsoft.AspNetCore.Mvc.MvcOptions[0]
Compatibility switch EnableEndpointRouting in type MvcOptions is using compatibility value True for version Version_2_2
dbug: Microsoft.AspNetCore.Mvc.MvcOptions[0]
Compatibility switch MaxValidationDepth in type MvcOptions is using compatibility value 32 for version Version_2_2
dbug: Microsoft.AspNetCore.Mvc.MvcOptions[0]
Compatibility switch AllowShortCircuitingValidationWhenNoValidatorsArePresent in type MvcOptions is using compatibility value True for version Version_2_2
dbug: Microsoft.AspNetCore.Mvc.ApiBehaviorOptions[0]
Compatibility switch SuppressMapClientErrors in type ApiBehaviorOptions is using default value False
dbug: Microsoft.AspNetCore.Mvc.ApiBehaviorOptions[0]
Compatibility switch SuppressUseValidationProblemDetailsForInvalidModelStateResponses in type ApiBehaviorOptions is using default value False
dbug: Microsoft.AspNetCore.Mvc.ApiBehaviorOptions[0]
Compatibility switch AllowInferringBindingSourceForCollectionTypesAsFromQuery in type ApiBehaviorOptions is using default value False
dbug: Microsoft.AspNetCore.Mvc.RazorPages.RazorPagesOptions[0]
Compatibility switch AllowAreas in type RazorPagesOptions is using compatibility value True for version Version_2_2
dbug: Microsoft.AspNetCore.Mvc.RazorPages.RazorPagesOptions[0]
Compatibility switch AllowMappingHeadRequestsToGetHandler in type RazorPagesOptions is using compatibility value True for version Version_2_2
dbug: Microsoft.AspNetCore.Mvc.RazorPages.RazorPagesOptions[0]
Compatibility switch AllowDefaultHandlingForOptionsRequests in type RazorPagesOptions is using compatibility value True for version Version_2_2
dbug: Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions[0]
Compatibility switch AllowRecompilingViewsOnFileChange in type RazorViewEngineOptions is using default value False
dbug: Microsoft.AspNetCore.Mvc.MvcViewOptions[0]
Compatibility switch SuppressTempDataAttributePrefix in type MvcViewOptions is using compatibility value True for version Version_2_2
dbug: Microsoft.AspNetCore.Mvc.MvcViewOptions[0]
Compatibility switch AllowRenderingMaxLengthAttribute in type MvcViewOptions is using compatibility value True for version Version_2_2
dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ModelBinderFactory[12]
Registered model binder providers, in the following order: Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ServicesModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.HeaderModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FloatingPointTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.EnumTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.SimpleTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.CancellationTokenModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ByteArrayModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormFileModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormCollectionModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.KeyValuePairModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.DictionaryModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ArrayModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.CollectionModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ComplexTypeModelBinderProvider
dbug: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[2]
Failed to locate the development https certificate at '(null)'.
warn: Microsoft.AspNetCore.Server.Kestrel[0]
Overriding address(es) 'https://*:5001'. Binding to endpoints defined in UseKestrel() instead.
dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[4]
Hosting started
dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[0]
Loaded hosting startup assembly HttpsDemo
Hosting environment: Production
Content root path: /app
Now listening on: https://127.0.0.1:5001
Application started. Press Ctrl+C to shut down.
@czd890: 证书问题?我证书是随便在网上下的一个