]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Earlier sanity check on reverse proxy settings
authorDylan Hardison <dylan@hardison.net>
Sat, 16 May 2020 02:25:32 +0000 (22:25 -0400)
committerDylan Hardison <dylan@hardison.net>
Sat, 16 May 2020 02:57:07 +0000 (22:57 -0400)
Bugzilla/App/Plugin/Hostage.pm

index fdf044e49b84e847966dbe50d29085e4a63b50e1..30afa65309ac96dbe12c43e999f2d6d0553199d2 100644 (file)
@@ -37,6 +37,8 @@ sub _before_routes {
   state $attachment_base       = Bugzilla->localconfig->attachment_base;
   state $attachment_root       = _attachment_root($attachment_base);
   state $attachment_host_regex = _attachment_host_regex($attachment_base);
+  state $urlbase_is_https      = $urlbase =~ /^https/;
+  state $behind_proxy          = Bugzilla->localconfig->inbound_proxies;
 
   my $stash = $c->stash;
   my $req   = $c->req;
@@ -51,6 +53,22 @@ sub _before_routes {
   }
 
   return if $stash->{'mojo.static'};
+
+  if ($urlbase_is_https && $behind_proxy && !$req->is_secure) {
+    my $error = "Reverse Proxy is Misconfigured";
+    $c->render(text => $error, status => 500);
+    unless ($ENV{MOJO_REVERSE_PROXY}) {
+      ERROR(
+        "$error: The environmental variable MOJO_REVERSE_PROXY should be set if operating Bugzilla behind a reverse proxy"
+      );
+    }
+    else {
+      ERROR(
+        "$error: Check that X-Forwarded-Proto and similar headers are being sent.");
+    }
+    return;
+  }
+
   return if $hostname eq $urlbase_host;
 
   my $path = $url->path;