Configures forwarded headers options
All checks were successful
Build, Push and Run Container / build (push) Successful in 32s
All checks were successful
Build, Push and Run Container / build (push) Successful in 32s
Configures the forwarded headers options to accept all forwarded headers, clears the default known networks and proxies, and adds a new known IP network to allow any IP address. This is necessary to handle requests from proxies and load balancers correctly.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
@@ -13,6 +14,7 @@ using ProofOfConcept.Models;
|
||||
using ProofOfConcept.Services;
|
||||
using ProofOfConcept.Utilities;
|
||||
using SzakatsA.Result;
|
||||
using IPNetwork = System.Net.IPNetwork;
|
||||
|
||||
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
|
||||
|
||||
@@ -150,8 +152,9 @@ builder.Services.AddHostedService<MQTTClient>();
|
||||
WebApplication app = builder.Build();
|
||||
|
||||
ForwardedHeadersOptions forwardedHeadersOptions = new ForwardedHeadersOptions() { ForwardedHeaders = ForwardedHeaders.All };
|
||||
forwardedHeadersOptions.KnownNetworks.Clear();
|
||||
forwardedHeadersOptions.KnownIPNetworks.Clear();
|
||||
forwardedHeadersOptions.KnownProxies.Clear();
|
||||
forwardedHeadersOptions.KnownIPNetworks.Add(new IPNetwork(IPAddress.Any, 0));
|
||||
forwardedHeadersOptions.ForwardLimit = null; // allow entire header chain, even if single hop
|
||||
forwardedHeadersOptions.RequireHeaderSymmetry = false; // don’t bail if headers aren’t “perfectly” paired
|
||||
|
||||
|
||||
Reference in New Issue
Block a user