Hosting and Deployment
Blazor Server is built on top of .NET Core, .NET Core is a cross platform framework. Taking advantage of .NET Core, Blazor Server websites can be hosted on both Linux and Windows OS. Regardless of the hosting OS, Blazor Server websites have 2 hosting models: Forward Proxy and Reverse Proxy.
Kestrel is a cross platform, default server for Blazor Server. The following image illustrates the relationship between Blazor Server and Kestrel.
Kestrel (or another hosting server) will take Program.cs
as the entry point for Blazor Server, then in the Program.cs
will use Startup.cs
by default to set up the environment. You can change the Startup.cs
to another Startup
class based on your needs. In most cases, you don't need to create another Startup
class.
Forward Proxy hosting
For simple websites, Forward Proxy hosting is the best choice because of the simplication when deploying a website. This image illustrates the Forward Proxy hosting model with Kestrel server.
In this hosting model, the Kestrel server must be bound directly to port 80 for HTTP protocol and 443 for HTTPS protocol. Any requests coming from the internet will call Kestrel directly to get a response.
Reverse Proxy hosting
For complicated websites, the Forward Proxy hosting model does not sustain the situation. You need to set up a Reverse Proxy hosting when:
- There is a risk of attacks like DDos.
- Port 80/443 are being used by another server.
- Load balancing.
This image illustrates the Reverse Proxy hosting model with Kestrel server.