mirror of
https://github.com/bitwarden/server.git
synced 2025-02-16 01:51:21 +01:00
command config for server, serve unknown files
This commit is contained in:
parent
9932c3b599
commit
cde50f4e6f
@ -1,3 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
dotnet /bitwarden_server/Server.dll /etc/bitwarden/core/attachments .
|
dotnet /bitwarden_server/Server.dll /contentRoot=/etc/bitwarden/core/attachments /webRoot=. /serveUnknown=true
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
namespace Server
|
namespace Server
|
||||||
{
|
{
|
||||||
@ -6,18 +7,25 @@ namespace Server
|
|||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
var config = new ConfigurationBuilder()
|
||||||
|
.AddCommandLine(args)
|
||||||
|
.Build();
|
||||||
|
|
||||||
var builder = new WebHostBuilder()
|
var builder = new WebHostBuilder()
|
||||||
|
.UseConfiguration(config)
|
||||||
.UseKestrel()
|
.UseKestrel()
|
||||||
.UseStartup<Startup>();
|
.UseStartup<Startup>();
|
||||||
|
|
||||||
if(args.Length > 0)
|
var contentRoot = config.GetValue<string>("contentRoot");
|
||||||
|
if(string.IsNullOrWhiteSpace(contentRoot))
|
||||||
{
|
{
|
||||||
builder.UseContentRoot(args[0]);
|
builder.UseContentRoot(contentRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.Length > 1)
|
var webRoot = config.GetValue<string>("webRoot");
|
||||||
|
if(string.IsNullOrWhiteSpace(webRoot))
|
||||||
{
|
{
|
||||||
builder.UseWebRoot(args[1]);
|
builder.UseWebRoot(webRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
var host = builder.Build();
|
var host = builder.Build();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Server
|
namespace Server
|
||||||
{
|
{
|
||||||
@ -8,9 +10,28 @@ namespace Server
|
|||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app)
|
public void Configure(
|
||||||
|
IApplicationBuilder app,
|
||||||
|
ILoggerFactory loggerFactory,
|
||||||
|
IConfiguration configuration)
|
||||||
{
|
{
|
||||||
app.UseFileServer();
|
loggerFactory
|
||||||
|
.AddConsole()
|
||||||
|
.AddDebug();
|
||||||
|
|
||||||
|
var serveUnknown = configuration.GetValue<bool?>("serveUnknown") ?? false;
|
||||||
|
if(serveUnknown)
|
||||||
|
{
|
||||||
|
app.UseStaticFiles(new StaticFileOptions
|
||||||
|
{
|
||||||
|
ServeUnknownFileTypes = true,
|
||||||
|
DefaultContentType = "application/octet-stream"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
app.UseFileServer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user