mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-24 05:27:30 +01:00
Add X-Accel-Buffering: no response header
This commit is contained in:
@@ -463,6 +463,9 @@ namespace Tgstation.Server.Host.Core
|
||||
// Add the X-Powered-By response header
|
||||
applicationBuilder.UseServerBranding(assemblyInformationProvider);
|
||||
|
||||
// Add the X-Accel-Buffering response header
|
||||
applicationBuilder.UseDisabledNginxProxyBuffering();
|
||||
|
||||
// suppress OperationCancelledExceptions, they are just aborted HTTP requests
|
||||
applicationBuilder.UseCancelledRequestSuppression();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
|
||||
@@ -165,6 +165,23 @@ namespace Tgstation.Server.Host.Extensions
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the X-Accel-Buffering response header.
|
||||
/// </summary>
|
||||
/// <param name="applicationBuilder">The <see cref="IApplicationBuilder"/> to configure.</param>
|
||||
/// <remarks>This is used to avoid interruption to SignalR streams by Nginx.</remarks>
|
||||
public static void UseDisabledNginxProxyBuffering(this IApplicationBuilder applicationBuilder)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(applicationBuilder);
|
||||
|
||||
// https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/#x-accel-buffering
|
||||
applicationBuilder.Use((context, next) =>
|
||||
{
|
||||
context.Response.Headers.Add("X-Accel-Buffering", "no");
|
||||
return next();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds additional global <see cref="LogContext"/> to the request pipeline.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user