.net core 如何配置Kestrel web服务器以使用我的生产服务器&x27;谁的ip地址?
目前我正在Ubuntu服务器上运行dotnet core mvc 3.1。 当我运行应用程序时,我看到:.net core 如何配置Kestrel web服务器以使用我的生产服务器&x27;谁的ip地址?,.net-core,kestrel-http-server,.net Core,Kestrel Http Server,目前我正在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
./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"
}
}
}
}
My 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>();
});
}
公共类程序
{
公共静态void Main(字符串[]args)
{
CreateHostBuilder(args.Build().Run();
}
公共静态IHostBuilder CreateHostBuilder(字符串[]args)=>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder=>
{
webBuilder.UseStartup();
});
}
我不明白为什么没有使用appsettings.Production.json文件,以及为什么没有使用我传递的环境变量
有什么帮助吗?也许您以前从未使用过Linux,但在那里设置环境变量需要您到底想做什么?要使用生产服务器的IP地址,只需将*或+绑定为URL
http://+:80
。它将侦听端口80(主Web服务器端口)上的所有接口。