Made it possible to configure proxies via env

In reference to #146
This commit is contained in:
Dan Brown 2017-12-07 19:46:25 +00:00
parent 06cf175b08
commit 56d5af1336
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
2 changed files with 20 additions and 0 deletions

View file

@ -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);
}
}

View file

@ -234,4 +234,6 @@ return [
],
'proxies' => env('APP_PROXIES', ''),
];