diff --git a/src/Microsoft.Tye.Hosting/DockerRunner.cs b/src/Microsoft.Tye.Hosting/DockerRunner.cs index 5c56c38c..5f9b4807 100644 --- a/src/Microsoft.Tye.Hosting/DockerRunner.cs +++ b/src/Microsoft.Tye.Hosting/DockerRunner.cs @@ -248,8 +248,14 @@ namespace Microsoft.Tye.Hosting // 1. Tell the docker container what port to bind to portString = docker.Private ? "" : string.Join(" ", ports.Select(p => $"-p {p.Port}:{p.ContainerPort ?? p.Port}")); + static bool IsHttp(string? protocol) + { + return string.Equals(protocol, "https", StringComparison.OrdinalIgnoreCase) || + string.Equals(protocol, "http", StringComparison.OrdinalIgnoreCase); + } + // 2. Configure ASP.NET Core to bind to those same ports - environment["ASPNETCORE_URLS"] = string.Join(";", ports.Select(p => $"{p.Protocol ?? "http"}://*:{p.ContainerPort ?? p.Port}")); + environment["ASPNETCORE_URLS"] = string.Join(";", ports.Where(p => IsHttp(p.Protocol)).Select(p => $"{p.Protocol}://*:{p.ContainerPort ?? p.Port}")); // Set the HTTPS port for the redirect middleware foreach (var p in ports) diff --git a/src/Microsoft.Tye.Hosting/ProcessRunner.cs b/src/Microsoft.Tye.Hosting/ProcessRunner.cs index 6c4e55df..9840ac34 100644 --- a/src/Microsoft.Tye.Hosting/ProcessRunner.cs +++ b/src/Microsoft.Tye.Hosting/ProcessRunner.cs @@ -172,8 +172,14 @@ namespace Microsoft.Tye.Hosting // These are the ports that the application should use for binding + static bool IsHttp(string? protocol) + { + return string.Equals(protocol, "https", StringComparison.OrdinalIgnoreCase) || + string.Equals(protocol, "http", StringComparison.OrdinalIgnoreCase); + } + // 1. Configure ASP.NET Core to bind to those same ports - environment["ASPNETCORE_URLS"] = string.Join(";", ports.Select(p => $"{p.Protocol ?? "http"}://{host}:{p.Port}")); + environment["ASPNETCORE_URLS"] = string.Join(";", ports.Where(p => IsHttp(p.Protocol)).Select(p => $"{p.Protocol}://{host}:{p.Port}")); // Set the HTTPS port for the redirect middleware foreach (var p in ports)