Skip to content

Instantly share code, notes, and snippets.

@PradeepLoganathan
Last active June 30, 2020 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PradeepLoganathan/0150137e29934169dac806d5355940f9 to your computer and use it in GitHub Desktop.
Save PradeepLoganathan/0150137e29934169dac806d5355940f9 to your computer and use it in GitHub Desktop.
forward ssl headers using forwarded headers middleware
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders =
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
options.KnownNetworks.Clear();
options.KnownProxies.Clear();
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseForwardedHeaders();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseMvc();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment