From 00d62b34239a0cabe9fac4cfaeab27b4173951f2 Mon Sep 17 00:00:00 2001 From: andofrjando Date: Sat, 16 Sep 2017 10:24:37 +0800 Subject: [PATCH 1/3] This fixes the following bug: If Pi-Hole is behind a reverse proxy that uses SSL, then the block page will not load resources such as `blockingpage.css` and `jquery.min.js` as the insecure `http://` is hard coded. Browsers will block attempts to load insecure resources if the page is loaded of SSL. The fix is acheived by checking `$_SERVER['HTTPS']` and setting the variable `$proto` to either `http` or `https`. The harcoded `http` is replaced by the contents of this variable. --- advanced/index.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/advanced/index.php b/advanced/index.php index 911f3cc8..5e88a050 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -28,7 +28,7 @@ $authorizedHosts = []; // Append FQDN to $authorizedHosts if (!empty($svFQDN)) array_push($authorizedHosts, $svFQDN); - + // Append virtual hostname to $authorizedHosts if (!empty($_SERVER["VIRTUAL_HOST"])) { array_push($authorizedHosts, $_SERVER["VIRTUAL_HOST"]); @@ -40,6 +40,15 @@ $validExtTypes = array("asp", "htm", "html", "php", "rss", "xml", ""); // Get extension of current URL $currentUrlExt = pathinfo($_SERVER["REQUEST_URI"], PATHINFO_EXTENSION); +// Check if this is served over HTTP or HTTPS +if(isset($_SERVER['HTTPS'])) { + if ($_SERVER['HTTPS'] == "on") { + $proto = "https"; + } else { + $proto = "http"; + } +} + // Set mobile friendly viewport $viewPort = ''; @@ -60,7 +69,7 @@ if ($serverName === "pi.hole") {
Pi-hole: Your black hole for Internet advertisements "; - + // Render splash page or landing page when directly browsing via IP or auth'd hostname $renderPage = is_file(getcwd()."/$landPage") ? include $landPage : "$splashPage"; unset($serverName, $svFQDN, $svPasswd, $svEmail, $authorizedHosts, $validExtTypes, $currentUrlExt, $viewPort); @@ -134,7 +143,7 @@ function queryAds($serverName) { } catch (Exception $e) { return array("0" => "error", "1" => $e->getMessage()); } - + } $queryAds = queryAds($serverName); @@ -201,10 +210,10 @@ if (explode("-", $phVersion)[1] != "0") - - + + ● <?=$serverName ?> - + +