Compare commits

...

1 Commits

Author SHA1 Message Date
David Fowler 2471a89725 Auto set ASPNETCORE_URLS only if the protocol is http or https 7 years ago
  1. 8
      src/Microsoft.Tye.Hosting/DockerRunner.cs
  2. 8
      src/Microsoft.Tye.Hosting/ProcessRunner.cs

8
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)

8
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)

Loading…
Cancel
Save