1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-01 13:43:23 +01:00

update decision tree for non-ssl use cases

This commit is contained in:
Kyle Spearrin 2018-03-28 21:18:10 -04:00
parent f21a25f917
commit 7de9b18aa6
2 changed files with 42 additions and 62 deletions

View File

@ -20,7 +20,7 @@ namespace Bit.Setup
} }
public bool MssqlDataDockerVolume { get; private set; } public bool MssqlDataDockerVolume { get; private set; }
public int HttpPort { get; private set; } = 80; public int HttpPort { get; private set; }
public int HttpsPort { get; private set; } public int HttpsPort { get; private set; }
public string CoreVersion { get; private set; } = "latest"; public string CoreVersion { get; private set; } = "latest";
public string WebVersion { get; private set; } = "latest"; public string WebVersion { get; private set; } = "latest";
@ -42,9 +42,10 @@ namespace Bit.Setup
public void BuildForUpdater() public void BuildForUpdater()
{ {
if(File.Exists("/bitwarden/docker/docker-compose.yml")) var composeFile = "/bitwarden/docker/docker-compose.yml";
if(File.Exists(composeFile))
{ {
var fileLines = File.ReadAllLines("/bitwarden/docker/docker-compose.yml"); var fileLines = File.ReadAllLines(composeFile);
foreach(var line in fileLines) foreach(var line in fileLines)
{ {
if(!line.StartsWith("# Parameter:")) if(!line.StartsWith("# Parameter:"))
@ -189,8 +190,13 @@ services:
image: bitwarden/nginx:{CoreVersion} image: bitwarden/nginx:{CoreVersion}
container_name: bitwarden-nginx container_name: bitwarden-nginx
restart: always restart: always
ports: ports:");
if(HttpPort != default(int))
{
sw.Write($@"
- '{HttpPort}:8080'"); - '{HttpPort}:8080'");
}
if(HttpsPort != default(int)) if(HttpsPort != default(int))
{ {

View File

@ -73,7 +73,6 @@ namespace Bit.Setup
{ {
Console.Write("(!) Do you have a SSL certificate to use? (y/n): "); Console.Write("(!) Do you have a SSL certificate to use? (y/n): ");
ssl = Console.ReadLine().ToLowerInvariant() == "y"; ssl = Console.ReadLine().ToLowerInvariant() == "y";
if(ssl) if(ssl)
{ {
Directory.CreateDirectory($"/bitwarden/ssl/{domain}/"); Directory.CreateDirectory($"/bitwarden/ssl/{domain}/");
@ -87,7 +86,7 @@ namespace Bit.Setup
var selfSignedSsl = certBuilder.BuildForInstall(); var selfSignedSsl = certBuilder.BuildForInstall();
ssl = certBuilder.Ssl; // Ssl prop can get flipped during the build ssl = certBuilder.Ssl; // Ssl prop can get flipped during the build
var url = ssl ? $"https://{domain}" : $"http://{domain}"; var url = $"https://{domain}";
Console.Write("(!) Do you want to use the default ports for HTTP (80) and HTTPS (443)? (y/n): "); Console.Write("(!) Do you want to use the default ports for HTTP (80) and HTTPS (443)? (y/n): ");
var defaultPorts = Console.ReadLine().ToLowerInvariant() == "y"; var defaultPorts = Console.ReadLine().ToLowerInvariant() == "y";
int httpPort = default(int), httpsPort = default(int); int httpPort = default(int), httpsPort = default(int);
@ -96,37 +95,26 @@ namespace Bit.Setup
httpPort = 80; httpPort = 80;
httpsPort = 443; httpsPort = 443;
} }
else else if(ssl)
{ {
Console.Write("(!) HTTP port: "); httpsPort = 443;
if(int.TryParse(Console.ReadLine().ToLowerInvariant().Trim(), out httpPort)) Console.Write("(!) HTTPS port: ");
if(int.TryParse(Console.ReadLine().ToLowerInvariant().Trim(), out httpsPort) && httpsPort != 443)
{ {
if(ssl) url += (":" + httpsPort);
{
Console.Write("(!) HTTPS port: ");
if(int.TryParse(Console.ReadLine().ToLowerInvariant().Trim(), out httpsPort))
{
if(httpsPort != 443)
{
url += (":" + httpsPort);
}
}
else
{
Console.WriteLine("Invalid HTTPS port. Using defaults.");
httpPort = 80;
httpsPort = 443;
}
}
else if(httpPort != 80)
{
url += (":" + httpPort);
}
} }
else else
{ {
Console.WriteLine("Invalid HTTP port. Using default."); Console.WriteLine("Using default port.");
httpPort = 80; }
}
else
{
httpPort = 80;
Console.Write("(!) HTTP port: ");
if(!int.TryParse(Console.ReadLine().ToLowerInvariant().Trim(), out httpPort) && httpPort != 80)
{
Console.WriteLine("Using default port.");
} }
} }
@ -134,46 +122,32 @@ namespace Bit.Setup
var reverseProxy = Console.ReadLine().ToLowerInvariant() == "y"; var reverseProxy = Console.ReadLine().ToLowerInvariant() == "y";
if(reverseProxy) if(reverseProxy)
{ {
Console.Write("(!) Do you use the default ports on your reverse proxy (80/443)? (y/n): "); Console.Write("(!) Do you use the default HTTPS port (443) on your reverse proxy? (y/n): ");
var proxyDefaultPorts = Console.ReadLine().ToLowerInvariant() == "y"; var proxyDefaultPort = Console.ReadLine().ToLowerInvariant() == "y";
if(proxyDefaultPort)
if(proxyDefaultPorts)
{ {
url = ssl ? $"https://{domain}" : $"http://{domain}"; url = $"https://{domain}";
} }
else else if(ssl)
{ {
int httpReversePort = default(int), httpsReversePort = default(int); Console.Write("(!) Proxy HTTPS port: ");
Console.Write("(!) Proxy HTTP port: "); if(int.TryParse(Console.ReadLine().ToLowerInvariant().Trim(), out var httpsReversePort)
if(int.TryParse(Console.ReadLine().ToLowerInvariant().Trim(), out httpReversePort)) && httpsReversePort != 443)
{ {
if(ssl) url += (":" + httpsReversePort);
{
Console.Write("(!) Proxy HTTPS port: ");
if(int.TryParse(Console.ReadLine().ToLowerInvariant().Trim(), out httpsReversePort))
{
if(httpsReversePort != 443)
{
url += (":" + httpsReversePort);
}
}
else
{
Console.WriteLine("Invalid proxy HTTPS port.");
httpReversePort = httpsReversePort = default(int);
}
}
else if(httpReversePort != 80)
{
url += (":" + httpReversePort);
}
} }
else else
{ {
Console.WriteLine("Invalid proxy HTTP port."); Console.WriteLine("Using default port.");
url = $"https://{domain}";
} }
} }
} }
else if(!ssl)
{
Console.WriteLine("ERROR: You must use a reverse proxy if not using SSL.");
return;
}
Console.Write("(!) Do you want to use push notifications? (y/n): "); Console.Write("(!) Do you want to use push notifications? (y/n): ");
var push = Console.ReadLine().ToLowerInvariant() == "y"; var push = Console.ReadLine().ToLowerInvariant() == "y";