0

Currently I am running dotnet core mvc 3.1 on a Ubuntu server. When I run the application I see this:

./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]

I have a appsettings.Product.json file also that has:

{
  "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 has:

    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>();
                });
    }

I am confused why the appsettings.Production.json file is not being used, and also why the environment variables I am passing are also not being used.

Any help?

Blankman
  • 259,732
  • 324
  • 769
  • 1,199
  • Maybe you never use Linux before, but setting environment variables there requires https://www.digitalocean.com/community/tutorials/how-to-read-and-set-environmental-and-shell-variables-on-a-linux-vps – Lex Li Mar 20 '20 at 15:21
  • What exactly are you trying to do? To use your production server's IP address just bind to * or + as the URL `http://+:80`. That will listen on all interfaces on port 80 (the main webserver port). – davidfowl May 05 '20 at 07:37

0 Answers0