Kestrel:Net Core的跨平臺服務器
阿新 • • 發佈:2018-06-30
timespan AD art com In sta pub nop ima
概述
Kestrel是一個基於libuv的跨平臺ASP.NET Core web服務器,libuv是一個跨平臺的異步I/O庫。ASP.NET Core項目默認使用Kestrel作為web服務器。
用戶可以單獨使用Kestrel,也可以配合IIS、Nginx、 Apache等反向代理服務器一塊使用;微軟官方建議後者配合使用,含蓄的說
Program.cs
public static void Main(string[] args) { BuildWebHost(args).Build().Run(); } public static IWebHostBuilder BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>();
.UseKestrel(options => { options.Limits.MaxConcurrentConnections = 100; options.Limits.MaxConcurrentUpgradedConnections = 100; options.Limits.MaxRequestBodySize = 10 * 1024; options.Limits.MinRequestBodyDataRate= new MinDataRate(bytesPerSecond: 100, gracePeriod: TimeSpan.FromSeconds(10)); options.Limits.MinResponseDataRate = new MinDataRate(bytesPerSecond: 100, gracePeriod: TimeSpan.FromSeconds(10)); options.Listen(IPAddress.Loopback, 5000); options.Listen(IPAddress.Loopback, 5001, listenOptions => { listenOptions.UseHttps("testCert.pfx", "testPassword"); }); });
文檔:
微軟官方:
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-2.1&tabs=aspnetcore2x
Nginx, or Apache
Kestrel:Net Core的跨平臺服務器