Skip to content

Commit

Permalink
Forward all proxied headers (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrizzlyOwl authored Jul 5, 2024
1 parent 4bdc808 commit e68d3e0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions TramsDataApi/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Text.Json.Serialization;
using Dfe.Academisation.CorrelationIdMiddleware;
using Microsoft.AspNetCore.HttpOverrides;

namespace TramsDataApi
{
Expand Down Expand Up @@ -122,6 +123,15 @@ public void ConfigureServices(IServiceCollection services)
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider provider)
{
// Ensure we do not lose X-Forwarded-* Headers when behind a Proxy
var forwardOptions = new ForwardedHeadersOptions {
ForwardedHeaders = ForwardedHeaders.All,
RequireHeaderSymmetry = false
};
forwardOptions.KnownNetworks.Clear();
forwardOptions.KnownProxies.Clear();
app.UseForwardedHeaders(forwardOptions);

app.UseSecurityHeaders(options =>
{
options.AddFrameOptionsDeny()
Expand Down

0 comments on commit e68d3e0

Please sign in to comment.