ASP.NET Core Interview Question #212
What is a reverse proxy and why is it used with ASP.NET Core?
Testing, Deployment & Hosting Senior Advanced
Quick Interview Answer
A reverse proxy receives client traffic and forwards it to one or more backend application servers. Examples of reverse-proxy roles include TLS termination, load balancing, host/path routing, request limits, compression, caching, and integration with a hosting platform.
Detailed Explanation
A reverse proxy receives client traffic and forwards it to one or more backend application servers. Examples of reverse-proxy roles include TLS termination, load balancing, host/path routing, request limits, compression, caching, and integration with a hosting platform.
When a proxy changes the apparent scheme, host, or client address, the ASP.NET Core application may need forwarded-header configuration so it can correctly understand the original request.
Only trusted proxies or networks should be allowed to supply forwarded information because these values can affect security-sensitive URL and client information.
Code Example
var options = new ForwardedHeadersOptions
{
ForwardedHeaders =
ForwardedHeaders.XForwardedFor |
ForwardedHeaders.XForwardedProto
};
app.UseForwardedHeaders(options);