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