Kestrel 就像 Apache Nginx 的角色 - daniel-qa/RooCode GitHub Wiki

Kestrel 就像 Apache / Nginx 的角色

Kestrel 就是 ASP.NET Core 的「內建 Web 伺服器」,幫你接收網路請求並交給程式碼處理,它快、穩、跨平台,是 ASP.NET Core 的好搭檔!

應用架構 伺服器角色 說明
PHP + Apache Apache 你用 Apache 處理 HTTP,然後呼叫 PHP 處理邏輯。
Node.js + Nginx Nginx + Node.js Nginx 接收外部請求,再轉給 Node.js App 處理。
ASP.NET Core + Kestrel Kestrel Kestrel 自己處理 HTTP 請求,就像 Node.js 自帶的 http.Server()

一般情況:不需特別管理 Kestrel

  • 開發階段:

dotnet run 自動幫你啟動 Kestrel。

port 預設綁定在 localhost:5000 / 5001。

檔案位置、TLS 憑證、binding 全部由 launchSettings.json 處理。

不需要自己設定 UseKestrel(),因為它已經預設開好了!

  • 部署在 Azure App Service:

Azure 背後就是跑 Kestrel,但你根本不用管,Azure 幫你包好了。