Config Linux
This commit is contained in:
@@ -17,6 +17,12 @@
|
||||
<ProjectReference Include="..\LaDOSE.Entity\LaDOSE.Entity.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="localhost.pfx">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
|
||||
@@ -22,21 +22,22 @@ namespace LaDOSE.Api
|
||||
|
||||
config = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appSettings.json", optional: true, reloadOnChange: true)
|
||||
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
||||
.Build();
|
||||
var certificateSettings = config.GetSection("certificateSettings");
|
||||
string certificateFileName = certificateSettings.GetValue<string>("filename");
|
||||
string certificatePassword = certificateSettings.GetValue<string>("password");
|
||||
//var certificateSettings = config.GetSection("CertificateSettings");
|
||||
//string certificateFileName = certificateSettings.GetValue<string>("filename");
|
||||
//string certificatePassword = certificateSettings.GetValue<string>("password");
|
||||
|
||||
X509Certificate2 certificate = new X509Certificate2(certificateFileName, certificatePassword);
|
||||
CreateWebHostBuilder(certificate,args).Build().Run();
|
||||
//X509Certificate2 certificate = new X509Certificate2(certificateFileName, certificatePassword);
|
||||
CreateWebHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IWebHostBuilder CreateWebHostBuilder(X509Certificate2 certificate, string[] args)
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
|
||||
{
|
||||
return WebHost.CreateDefaultBuilder(args)
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseConfiguration(config)
|
||||
.UseKestrel(options => options.Listen(IPAddress.Loopback,int.Parse(config["Port"]),config=> config.UseHttps(certificate)))
|
||||
.UseKestrel(options => options.Listen(IPAddress.Loopback,int.Parse(config["Port"])))
|
||||
.UseStartup<Startup>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,14 @@ namespace LaDOSE.Api
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
var MySqlServer = this.Configuration["MySql:Server"];
|
||||
var MySqlDatabase = this.Configuration["MySql:Database"];
|
||||
var MySqlUser = this.Configuration["MySql:User"];
|
||||
var MySqlPassword = this.Configuration["MySql:Password"];
|
||||
services.AddCors();
|
||||
services.AddMvc();
|
||||
services.AddDbContextPool<LaDOSEDbContext>( // replace "YourDbContext" with the class name of your DbContext
|
||||
options => options.UseMySql("Server=localhost;Database=ladose;User=root;Password=;", // replace with your Connection String
|
||||
options => options.UseMySql($"Server={MySqlServer};Database={MySqlDatabase};{MySqlUser}=root;Password={MySqlPassword};", // replace with your Connection String
|
||||
mysqlOptions =>
|
||||
{
|
||||
mysqlOptions.ServerVersion(new Version(10, 1, 16), ServerType.MariaDb); // replace with your Server Version and Type
|
||||
|
||||
@@ -4,10 +4,16 @@
|
||||
"Default": "Warning"
|
||||
}
|
||||
},
|
||||
"certificateSettings": {
|
||||
"CertificateSettings": {
|
||||
"fileName": "localhost.pfx",
|
||||
"password": "YourSecurePassword"
|
||||
},
|
||||
"MySql": {
|
||||
"Server": "host",
|
||||
"Database": "database",
|
||||
"User": "User",
|
||||
"Password": "Password"
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Port": 5000,
|
||||
"JWTTokenSecret": "here goes the custom Secret key for authnetication"
|
||||
|
||||
Reference in New Issue
Block a user