Added Collection Extensions, Updated DateTimeExtensions
This commit is contained in:
@@ -16,26 +16,32 @@ namespace Microsoft.AspNetCore.Builder
|
||||
/// Adds settings to run behind a reverse proxy (e.g. NginX).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A base path (e.g. running in a sub-directory /app) for the application is defined via <c>ASPNETCORE_APPL_PATH</c> environment variable.
|
||||
/// A base path (e.g. running in a sub-directory /app) for the application can be defined via <c>ASPNETCORE_APPL_PATH</c> environment variable.
|
||||
/// <br/>
|
||||
/// <br/>
|
||||
/// Additionally you can specify the proxy server by using <paramref name="address"/> or a <paramref name="network"/> when there are multiple proxy servers.
|
||||
/// <br/>
|
||||
/// When no <paramref name="address"/> oder <paramref name="network"/> is set, the default subnets are configured:<br/>
|
||||
/// - <c>127.0.0.0/8</c><br/>
|
||||
/// - <c>10.0.0.0/8</c><br/>
|
||||
/// - <c>172.16.0.0/12</c><br/>
|
||||
/// - <c>192.168.0.0/16</c><br/>
|
||||
/// When neither <paramref name="address"/> nor <paramref name="network"/> is set, the default subnets are configured:
|
||||
/// <list type="bullet">
|
||||
/// <item><c>127.0.0.0/8</c></item>
|
||||
/// <item><c>::1/128</c></item>
|
||||
///
|
||||
/// - <c>::1/128</c><br/>
|
||||
/// - <c>fd00::/8</c>
|
||||
/// <item><c>10.0.0.0/8</c></item>
|
||||
/// <item><c>172.16.0.0/12</c></item>
|
||||
/// <item><c>192.168.0.0/16</c></item>
|
||||
/// <item><c>fd00::/8</c></item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
/// <param name="app">The application builder.</param>
|
||||
/// <param name="network">The <see cref="IPNetwork"/> where proxy requests are received from (optional).</param>
|
||||
/// <param name="address">The <see cref="IPAddress"/> where proxy requests are received from (optional).</param>
|
||||
public static IApplicationBuilder UseProxyHosting(this IApplicationBuilder app, IPNetwork network = null, IPAddress address = null)
|
||||
/// <param name="basePath">A custom base path (optional, <c>ASPNETCORE_APPL_PATH</c> is prefererred).</param>
|
||||
public static IApplicationBuilder UseProxyHosting(this IApplicationBuilder app, IPNetwork network = null, IPAddress address = null, string basePath = null)
|
||||
{
|
||||
string path = Environment.GetEnvironmentVariable("ASPNETCORE_APPL_PATH");
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
path = basePath;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(path))
|
||||
app.UsePathBase(new PathString(path));
|
||||
|
||||
@@ -46,15 +52,17 @@ namespace Microsoft.AspNetCore.Builder
|
||||
if (network == null && address == null)
|
||||
{
|
||||
// localhost
|
||||
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("127.0.0.0"), 8));
|
||||
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("::1"), 128));
|
||||
options.KnownNetworks.Add(new IPNetwork(IPAddress.Loopback, 8));
|
||||
options.KnownNetworks.Add(new IPNetwork(IPAddress.IPv6Loopback, 128));
|
||||
|
||||
// private IPv4 networks
|
||||
// see https://en.wikipedia.org/wiki/Private_network#Private_IPv4_addresses
|
||||
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("10.0.0.0"), 8));
|
||||
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("172.16.0.0"), 12));
|
||||
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("192.168.0.0"), 16));
|
||||
|
||||
// private IPv6 networks
|
||||
// see https://en.wikipedia.org/wiki/Private_network#Private_IPv6_addresses
|
||||
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("fd00::"), 8));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user