BookStack/app/Http/Middleware/TrustProxies.php

44 lines
985 B
PHP
Raw Normal View History

2017-11-19 23:56:06 +08:00
<?php
namespace BookStack\Http\Middleware;
use Closure;
2017-11-19 23:56:06 +08:00
use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;
2017-11-19 23:56:06 +08:00
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array
*/
protected $proxies;
/**
2019-09-07 05:14:39 +08:00
* The headers that should be used to detect proxies.
2017-11-19 23:56:06 +08:00
*
2019-09-07 05:14:39 +08:00
* @var int
2017-11-19 23:56:06 +08:00
*/
2019-09-07 05:14:39 +08:00
protected $headers = Request::HEADER_X_FORWARDED_ALL;
/**
* Handle the request, Set the correct user-configured proxy information.
2021-06-26 23:23:15 +08:00
*
* @param Request $request
* @param Closure $next
2021-06-26 23:23:15 +08:00
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
$setProxies = config('app.proxies');
if ($setProxies !== '**' && $setProxies !== '*' && $setProxies !== '') {
$setProxies = explode(',', $setProxies);
}
$this->proxies = $setProxies;
return parent::handle($request, $next);
}
2017-11-19 23:56:06 +08:00
}