From the course: Deploying ASP.NET Core Applications

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Configure Forwarded Headers Middleware

Configure Forwarded Headers Middleware

From the course: Deploying ASP.NET Core Applications

Start my 1-month free trial

Configure Forwarded Headers Middleware

- [Instructor] The forwarded headers middleware component helps your ASP.NET Core application to look for headers added by an upstream proxy or load balancer. How you configure the middleware depends on how you plan to host your application. If you're hosting with IaaS on Windows, you don't have to do anything, this middleware is already enabled by default. If you're using another proxy besides IaaS, open up your startup.cs file and add a line to the configure method. We'll do app.UseForwardedHeaders, and then pass in options, new ForwardedHeadersOptions, and we'll say ForwardedHeaders = ForwardedHeaders, let's go ahead and import this namespace, ForwardedHeaders, import that with control dot, .XForwardedFor or ForwardedHeaders.XForwardedProto. There's a few important things to note here. First, it's important that the use forwarded headers middleware is high up in the middleware pipeline, above things like use https redirection, use static files, use mvc, or use authentication…

Contents