Skip to content

NOW MANAGED ON CODEBERG

Made it possible to configure proxies via env

Dan Brown56d5af1336d8
diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php
index 69fcbe943..c3102571d 100644
--- a/app/Http/Middleware/TrustProxies.php
+++ b/app/Http/Middleware/TrustProxies.php
@@ -2,6 +2,7 @@
namespace BookStack\Http\Middleware;
+use Closure;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;
@@ -26,4 +27,21 @@ class TrustProxies extends Middleware
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
];
+
+ /**
+ * Handle the request, Set the correct user-configured proxy information.
+ * @param Request $request
+ * @param Closure $next
+ * @return mixed
+ */
+ public function handle($request, Closure $next)
+ {
+ $setProxies = config('app.proxies');
+ if ($setProxies !== '**' && $setProxies !== '*' && $setProxies !== '') {
+ $setProxies = explode(',', $setProxies);
+ }
+ $this->proxies = $setProxies;
+
+ return parent::handle($request, $next);
+ }
}
diff --git a/config/app.php b/config/app.php
index d8def5c95..3be50b6c5 100755
--- a/config/app.php
+++ b/config/app.php
@@ -234,4 +234,6 @@ return [
],
+ 'proxies' => env('APP_PROXIES', ''),
+
];