mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-02 05:43:40 +08:00
f139cded78
* Temporarily moved back config path * Apply Laravel coding style * Shift exception handler * Shift HTTP kernel and middleware * Shift service providers * Convert options array to fluent methods * Shift to class based routes * Shift console routes * Ignore temporary framework files * Shift to class based factories * Namespace seeders * Shift PSR-4 autoloading * Shift config files * Default config files * Shift Laravel dependencies * Shift return type of base TestCase methods * Shift cleanup * Applied stylci style changes * Reverted config files location * Applied manual changes to Laravel 8 shift Co-authored-by: Shift <shift@laravelshift.com>
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace BookStack\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
|
use Illuminate\Http\Request;
|
|
|
|
class TrustProxies extends Middleware
|
|
{
|
|
/**
|
|
* The trusted proxies for this application.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $proxies;
|
|
|
|
/**
|
|
* The headers that should be used to detect proxies.
|
|
*
|
|
* @var int
|
|
*/
|
|
protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_AWS_ELB;
|
|
|
|
/**
|
|
* Handle the request, Set the correct user-configured proxy information.
|
|
*
|
|
* @param Request $request
|
|
* @param Closure $next
|
|
*
|
|
* @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);
|
|
}
|
|
}
|