|
|
@ -88,71 +88,78 @@ namespace Jellyfin.Server
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="app">The application builder.</param>
|
|
|
|
/// <param name="app">The application builder.</param>
|
|
|
|
/// <param name="env">The webhost environment.</param>
|
|
|
|
/// <param name="env">The webhost environment.</param>
|
|
|
|
/// <param name="serverApplicationHost">The server application host.</param>
|
|
|
|
|
|
|
|
/// <param name="appConfig">The application config.</param>
|
|
|
|
/// <param name="appConfig">The application config.</param>
|
|
|
|
public void Configure(
|
|
|
|
public void Configure(
|
|
|
|
IApplicationBuilder app,
|
|
|
|
IApplicationBuilder app,
|
|
|
|
IWebHostEnvironment env,
|
|
|
|
IWebHostEnvironment env,
|
|
|
|
IServerApplicationHost serverApplicationHost,
|
|
|
|
|
|
|
|
IConfiguration appConfig)
|
|
|
|
IConfiguration appConfig)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Only add base url redirection if a base url is set.
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_serverConfigurationManager.Configuration.BaseUrl))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
app.UseBaseUrlRedirection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Wrap rest of configuration so everything only listens on BaseUrl.
|
|
|
|
|
|
|
|
app.Map(_serverConfigurationManager.Configuration.BaseUrl, mainApp =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (env.IsDevelopment())
|
|
|
|
if (env.IsDevelopment())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
mainApp.UseDeveloperExceptionPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
app.UseMiddleware<ExceptionMiddleware>();
|
|
|
|
mainApp.UseMiddleware<ExceptionMiddleware>();
|
|
|
|
|
|
|
|
|
|
|
|
app.UseMiddleware<ResponseTimeMiddleware>();
|
|
|
|
mainApp.UseMiddleware<ResponseTimeMiddleware>();
|
|
|
|
|
|
|
|
|
|
|
|
app.UseWebSockets();
|
|
|
|
mainApp.UseWebSockets();
|
|
|
|
|
|
|
|
|
|
|
|
app.UseResponseCompression();
|
|
|
|
mainApp.UseResponseCompression();
|
|
|
|
|
|
|
|
|
|
|
|
app.UseCors(ServerCorsPolicy.DefaultPolicyName);
|
|
|
|
mainApp.UseCors(ServerCorsPolicy.DefaultPolicyName);
|
|
|
|
|
|
|
|
|
|
|
|
if (_serverConfigurationManager.Configuration.RequireHttps
|
|
|
|
if (_serverConfigurationManager.Configuration.RequireHttps
|
|
|
|
&& _serverApplicationHost.ListenWithHttps)
|
|
|
|
&& _serverApplicationHost.ListenWithHttps)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
mainApp.UseHttpsRedirection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
app.UseStaticFiles();
|
|
|
|
mainApp.UsePathBase(_serverConfigurationManager.Configuration.BaseUrl);
|
|
|
|
app.UsePathBase(_serverConfigurationManager.Configuration.BaseUrl);
|
|
|
|
mainApp.UseStaticFiles();
|
|
|
|
if (appConfig.HostWebClient())
|
|
|
|
if (appConfig.HostWebClient())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
app.UseStaticFiles(new StaticFileOptions
|
|
|
|
mainApp.UseStaticFiles(new StaticFileOptions
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FileProvider = new PhysicalFileProvider(_serverConfigurationManager.ApplicationPaths.WebPath),
|
|
|
|
FileProvider = new PhysicalFileProvider(_serverConfigurationManager.ApplicationPaths.WebPath),
|
|
|
|
RequestPath = "/web"
|
|
|
|
RequestPath = "/web"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
app.UseAuthentication();
|
|
|
|
mainApp.UseAuthentication();
|
|
|
|
app.UseJellyfinApiSwagger(_serverConfigurationManager);
|
|
|
|
mainApp.UseJellyfinApiSwagger(_serverConfigurationManager);
|
|
|
|
app.UseRouting();
|
|
|
|
mainApp.UseRouting();
|
|
|
|
app.UseAuthorization();
|
|
|
|
mainApp.UseAuthorization();
|
|
|
|
if (_serverConfigurationManager.Configuration.EnableMetrics)
|
|
|
|
if (_serverConfigurationManager.Configuration.EnableMetrics)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Must be registered after any middleware that could change HTTP response codes or the data will be bad
|
|
|
|
// Must be registered after any middleware that could change HTTP response codes or the data will be bad
|
|
|
|
app.UseHttpMetrics();
|
|
|
|
mainApp.UseHttpMetrics();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
app.UseLanFiltering();
|
|
|
|
mainApp.UseLanFiltering();
|
|
|
|
app.UseIpBasedAccessValidation();
|
|
|
|
mainApp.UseIpBasedAccessValidation();
|
|
|
|
app.UseBaseUrlRedirection();
|
|
|
|
mainApp.UseWebSocketHandler();
|
|
|
|
app.UseWebSocketHandler();
|
|
|
|
mainApp.UseServerStartupMessage();
|
|
|
|
app.UseServerStartupMessage();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
|
mainApp.UseEndpoints(endpoints =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
endpoints.MapControllers();
|
|
|
|
endpoints.MapControllers();
|
|
|
|
if (_serverConfigurationManager.Configuration.EnableMetrics)
|
|
|
|
if (_serverConfigurationManager.Configuration.EnableMetrics)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
endpoints.MapMetrics(_serverConfigurationManager.Configuration.BaseUrl.TrimStart('/') + "/metrics");
|
|
|
|
endpoints.MapMetrics("/metrics");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
endpoints.MapHealthChecks(_serverConfigurationManager.Configuration.BaseUrl.TrimStart('/') + "/health");
|
|
|
|
endpoints.MapHealthChecks("/health");
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Add type descriptor for legacy datetime parsing.
|
|
|
|
// Add type descriptor for legacy datetime parsing.
|
|
|
|