aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2019-09-29 17:22:40 -0400
committerGitHub <noreply@github.com>2019-09-29 17:22:40 -0400
commit749023bf02c9797ce2e0b5142fb2ddd27e682df0 (patch)
tree3e0df051e8592fbf98a2e1df307ae66de1f3ca9b
parentdcc8c7b92a546274c92711e1ebdbb022b6704984 (diff)
parent387192610f5aca62e691dfe2dfed92a5889c6cd7 (diff)
Merge pull request #1811 from joshuaboniface/fix-listen
Configure Kestrel listener to use configured IPs
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs39
1 files changed, 35 insertions, 4 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index 1d0293a5f..d22f2be81 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -615,11 +615,34 @@ namespace Emby.Server.Implementations
var host = new WebHostBuilder()
.UseKestrel(options =>
{
- options.ListenAnyIP(HttpPort);
+ var addresses = ServerConfigurationManager
+ .Configuration
+ .LocalNetworkAddresses
+ .Select(NormalizeConfiguredLocalAddress)
+ .Where(i => i != null)
+ .ToList();
+ if (addresses.Any())
+ {
+ foreach (var address in addresses)
+ {
+ Logger.LogInformation("Kestrel listening on {ipaddr}", address);
+ options.Listen(address, HttpPort);
- if (EnableHttps && Certificate != null)
+ if (EnableHttps && Certificate != null)
+ {
+ options.Listen(address, HttpsPort, listenOptions => listenOptions.UseHttps(Certificate));
+ }
+ }
+ }
+ else
{
- options.ListenAnyIP(HttpsPort, listenOptions => listenOptions.UseHttps(Certificate));
+ Logger.LogInformation("Kestrel listening on all interfaces");
+ options.ListenAnyIP(HttpPort);
+
+ if (EnableHttps && Certificate != null)
+ {
+ options.ListenAnyIP(HttpsPort, listenOptions => listenOptions.UseHttps(Certificate));
+ }
}
})
.UseContentRoot(contentRoot)
@@ -640,7 +663,15 @@ namespace Emby.Server.Implementations
})
.Build();
- await host.StartAsync().ConfigureAwait(false);
+ try
+ {
+ await host.StartAsync().ConfigureAwait(false);
+ }
+ catch (Exception ex)
+ {
+ Logger.LogError("Kestrel failed to start! This is most likely due to an invalid address or port bind - correct your bind configuration in system.xml and try again.");
+ throw;
+ }
}
private async Task ExecuteWebsocketHandlerAsync(HttpContext context, Func<Task> next)