From afd72b26eba0418fce1ed2a86f01fb7ec4e1f3fa Mon Sep 17 00:00:00 2001 From: Viktor Hansson Date: Mon, 20 Nov 2017 13:53:38 +0100 Subject: [PATCH] Support for reverse proxy in setup script (#139) * Added option for when using reverse proxy to setup script * Removed debug console.write --- util/Setup/Program.cs | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/util/Setup/Program.cs b/util/Setup/Program.cs index dd2e49135..af64d5aa5 100644 --- a/util/Setup/Program.cs +++ b/util/Setup/Program.cs @@ -123,6 +123,51 @@ namespace Bit.Setup } } + Console.Write("(!) Is your installation behind a reverse proxy? (y/n): "); + var reverseProxy = Console.ReadLine().ToLowerInvariant() == "y"; + if(reverseProxy) + { + Console.Write("(!) Do you use the default ports on your reverse proxy (80/443)? (y/n): "); + var proxyDefaultPorts = Console.ReadLine().ToLowerInvariant() == "y"; + + if(proxyDefaultPorts) + { + url = ssl ? $"https://{domain}" : $"http://{domain}"; + } + else + { + int httpReversePort = default(int), httpsReversePort = default(int); + Console.Write("(!) HTTP port: "); + if(int.TryParse(Console.ReadLine().ToLowerInvariant().Trim(), out httpReversePort)) + { + if(ssl) + { + Console.Write("(!) HTTPS port: "); + if(int.TryParse(Console.ReadLine().ToLowerInvariant().Trim(), out httpsReversePort)) + { + if(httpsReversePort != 443) + { + url += (":" + httpsReversePort); + } + } + else + { + Console.WriteLine("Invalid HTTPS port."); + httpReversePort = httpsReversePort = default(int); + } + } + else if(httpReversePort != 80) + { + url += (":" + httpReversePort); + } + } + else + { + Console.WriteLine("Invalid HTTP port."); + } + } + } + Console.Write("(!) Do you want to use push notifications? (y/n): "); var push = Console.ReadLine().ToLowerInvariant() == "y";