I was reading about Kestrel
web server in asp.net core app
specifically the in-process http server
and reverse proxy
.
Being a seasonal web developer, I have trouble in understanding the idea behind:
in-process http server
implementation in core application ?web server
?http request
?reverse proxy
and Kestrel
correlate / communicate (1:n
or 1:1
) if the asp.net core app is meant to be deployed in a container?A reverse proxy is a special type of proxy server that hides the target server to the client. The client requests a resource to the proxy server which retrieves it from another server and provides it to the client. In this case, the client has no idea that the resource comes from another server.
With its lightweight component, Kestrel has better single and concurrent request processing ability over the IIS server.
HTTPS Redirection Middleware (UseHttpsRedirection) to redirect HTTP requests to HTTPS. HSTS Middleware (UseHsts) to send HTTP Strict Transport Security Protocol (HSTS) headers to clients.
WebListener is a web server for ASP.NET Core that runs only on Windows. It's built on the Http. Sys kernel mode driver. WebListener is an alternative to Kestrel that can be used for direct connection to the Internet without relying on IIS as a reverse proxy server.
According to official documentation:
ASP.NET Core was designed to run in its own process so that it can behave consistently across platforms. IIS, Nginx, and Apache dictate their own startup process and environment; to use them directly, ASP.NET Core would have to adapt to the needs of each one. Using a web server implementation such as Kestrel gives ASP.NET Core control over the startup process and environment. So rather than trying to adapt ASP.NET Core to IIS, Nginx, or Apache, you just set up those web servers to proxy requests to Kestrel. This arrangement allows your Program.Main and Startup classes to be essentially the same no matter where you deploy.
Besides that having the in-process http server makes stuff really easier for developers. They just download the framework, install it and it works out of the box no matter what OS they are using (Windows, Linux or MacOS) or what web server they want to use later. They just fire dotnet run
command which starts the http server with a web app hosting on it.
While it's OK to run it in a development environment when an app is ready for production developers should remember about security. The Kestrel web server is very new web server so it doesn't have all that security and other useful features as IIS, Apache or Nginx obtained during their long lives. This is the only reason why MS recommends to use reverse-proxy in production environment. The goal of reverse proxy is not only forward requests to in-process http server, but also be responsible for security, compression and other features a good web server may provide.
As for container deployments it really depends on what you want to achieve. There are different scenarios:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With