简体   繁体   中英

Failed to determine the https port for redirect in Docker

I'm trying to deploy an asp.net-core webapi service which is exposed from 80 port using:

docker run --rm -p 80:80 --name radicadorrest -it radicadorrest

error:

warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35] No XML encryptor configured. Key {e60978fd-16bc-4ff2-8525-39b5d0c36be5} may be persisted to storage in unencrypted form. Hosting environment: Production Content root path: /app Now listening on: http://[::]:80 Application started. Press Ctrl+C to shut down.

warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3] Failed to determine the https port for redirect. Application is shutting down...

I have tried using different ports but I get the same error.

Docker version:

Client: Version: 17.09.1-ce
API version: 1.32
Go version: go1.8.3
Git commit: 19e2cf6
Built: Thu Dec 7 22:25:13 2017
OS/Arch: linux/amd64

Server: Version: 17.09.1-ce
API version: 1.32 (minimum version1.12)
Go version: go1.8.3
Git commit: 19e2cf6
Built: Thu Dec 7 22:26:35 2017 OS/Arch: linux/amd64 Experimental:false

I have also trying on Windows with the same result.

The two warnings are totally unrelated.

For the DataProtection warning, I recommend following the guidance presented here on the official ASP.Net Core documents . If you care to dig in deeper as to the relevant source code and decision, you can see this relevant ASP.Net GitHub PR .

For the https redirection warning, I recommend simply removing the https redirection policy from the startup.cs file which is typically defined via app.UseHttpsRedirection(); unless you're actually using this policy for your container and in this case you'd need to actually setup the certificates and expose the HTTPS port on your container.

This is because when you created the ASP.NET Core project you selected the option "Configure for HTTPS". This adds the HttpsRedirectionMiddleware middleware which enforces SSL connections for your web app. The docker file you created is only specifying the HTTP port. Hence the HttpsRedirectionMiddleware is failing and shutting down the application. Basically if you had not selected the "Configure for HTTPS" option while you created the project you would be fine or ensure the SSL is setup properly (ports and certs).

您的端口仅指定http协议而不是https,您可能必须找到一种方法使docker仅查看80并忽略用于https的443端口

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM