.net-core - 如何配置 Kestrel Web 服务器以使用我的生产服务器的 IP 地址?
问题描述
目前我在 Ubuntu 服务器上运行 dotnet core mvc 3.1。当我运行应用程序时,我看到:
./MyApp.Web ASPNETCORE_ENVIRONMENT=Production ASPNETCORE_URLS=http://1.2.3.4/
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using '/root/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /root/apps
^Cinfo: Microsoft.Hosting.Lifetime[0]
我有一个 appsettings.Product.json 文件也有:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Redis": {
"Host": "localhost",
"Port": "6379"
},
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://1.2.3.4"
}
}
}
}
我的 Program.cs 有:
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
我很困惑为什么没有使用 appsettings.Production.json 文件,以及为什么我传递的环境变量也没有被使用。
有什么帮助吗?
解决方案
推荐阅读
- sql - 在 Postgresql 中,如何找到在一个时间范围内仅发生第一个事件的 3 个连续事件?
- php - 在我的 html 网站上显示 php 文件的输出(回显)
- android - Android Studio 中的 AppComparActivity.class 有什么用?我可以将我的方法作为父类写在上面吗?
- python - ScalarQueryParameter 返回类型错误:“列表对象不可调用”
- docker - Docker 是在桌面上运行的安全威胁吗?
- android - Gradle 偶尔会失败,并显示“任务 ':app:generateJsonModelRelease' 执行失败:格式说明符 '%s'”
- java - Android - Webview 获取页面加载时间
- codenameone - 如何在 CN1 中创建此用户界面?
- php - 假设 https 用于两者,PHP 会话是否比 ajax 调用更安全?
- sql-server - 如何为ssis的oledb目标中的列分配一个常量值