diff --git a/Hippo/Program.cs b/Hippo/Program.cs index df4c066e5..431006a5d 100644 --- a/Hippo/Program.cs +++ b/Hippo/Program.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Threading.Tasks; using Hippo.Config; @@ -20,6 +21,8 @@ public static class Program { // TODO get value from configuration. public static string JobScheduler => Environment.GetEnvironmentVariable("HIPPO_JOB_SCHEDULER")?.ToUpperInvariant() ?? default; + private static string proxyPort = string.Empty; + public static string ProxyPort => Program.proxyPort; public static void Main(string[] args) { @@ -43,11 +46,29 @@ public static void Main(string[] args) var proxyUpdateTaskQueue = hippoHost.Services.GetRequiredService>(); var proxyHostBuilder = CreateProxyHostBuilder(proxyUpdateTaskQueue); var proxyHost = proxyHostBuilder.Build(); + proxyPort = GetProxyHTTPSPort(proxyHost.Services.GetRequiredService()); tasks.Add(hippoHost.RunAsync()); tasks.Add(proxyHost.RunAsync()); Task.WaitAny(tasks.ToArray()); } + /// + /// Gets the HTTPS Proxy port so that links can be created correctly in the Hippo UI. this will need to be updated for external schedulers. + /// + /// The Proxy Configuration + /// The proy HTTPS Port as a string + + static string GetProxyHTTPSPort(IConfiguration config) + { + var port = string.Empty; + var proxyUrl = config?.GetValue("Kestrel:Endpoints:Https:Url"); + if (!string.IsNullOrEmpty(proxyUrl) && Uri.TryCreate(proxyUrl, UriKind.Absolute, out Uri result)) + { + port = result.Port == 0 || result.Port == 443 ? string.Empty : $":{result.Port.ToString(CultureInfo.InvariantCulture)}"; + } + return port; + } + // This has to be called CreateHostBuilder because the ef migrations tool looks specifically // for that method name. // NOTE do not run the ef migrations tool with env var HIPPO_JOB_SCHEDULER set to WAGI-DOTNET as it will fail. diff --git a/Hippo/Views/Shared/_NavSidebar.cshtml b/Hippo/Views/Shared/_NavSidebar.cshtml index f121212bb..c3f03932c 100644 --- a/Hippo/Views/Shared/_NavSidebar.cshtml +++ b/Hippo/Views/Shared/_NavSidebar.cshtml @@ -43,7 +43,7 @@ @Html.DisplayFor(modelItem => item.Name)

- + @Html.DisplayFor(modelItem => item.Domain.Name)