]> BookStack Code Mirror - bookstack/blob - app/Http/Middleware/TrustProxies.php
Update settings.php
[bookstack] / app / Http / Middleware / TrustProxies.php
1 <?php
2
3 namespace BookStack\Http\Middleware;
4
5 use Closure;
6 use Fideloper\Proxy\TrustProxies as Middleware;
7 use Illuminate\Http\Request;
8
9 class TrustProxies extends Middleware
10 {
11     /**
12      * The trusted proxies for this application.
13      *
14      * @var array
15      */
16     protected $proxies;
17
18     /**
19      * The headers that should be used to detect proxies.
20      *
21      * @var int
22      */
23     protected $headers = Request::HEADER_X_FORWARDED_ALL;
24
25     /**
26      * Handle the request, Set the correct user-configured proxy information.
27      * @param Request $request
28      * @param Closure $next
29      * @return mixed
30      */
31     public function handle(Request $request, Closure $next)
32     {
33         $setProxies = config('app.proxies');
34         if ($setProxies !== '**' && $setProxies !== '*' && $setProxies !== '') {
35             $setProxies = explode(',', $setProxies);
36         }
37         $this->proxies = $setProxies;
38
39         return parent::handle($request, $next);
40     }
41 }