CheckForTrustedProxies

Enables support for trusted proxies in requests.

 class Winter\Storm\Foundation\Http\Middleware\CheckForTrustedProxies

Allows for trusted proxies to provide secure assets in a request even if PHP itself is declaring that HTTPS is inactive, which is the case for a lot of common DNS, caching and load balancing providers such as Amazon Elastic Load Balancing, CloudFlare, etc.

Proxies should be defined in the config/app.php file within the trustedProxies configuration variable.

Based off the implementation from https://github.com/fideloper/TrustedProxy.

Properties

protected $app : Illuminate\Contracts\Foundation\Application

The application instance.

Methods

public __construct (Illuminate\Contracts\Foundation\Application $app) : void

Create a new middleware instance.

Parameters
Property Description
$app
Illuminate\Contracts\Foundation\Application
Returns
void

public handle (Illuminate\Http\Request $request, Closure $next) : mixed

Handle an incoming request.

Parameters
Property Description
$request
Illuminate\Http\Request
$next
Closure
Returns
mixed

public headers () : int

Get proxy headers to trust.

Returns
int

public proxies () : array | string | false | null

Get proxies defined in configuration.

Returns
array | string | false | null

protected allowProxies (Illuminate\Http\Request $request, array $proxies) : void

Allows the given IP addresses to be trusted as proxies.

Parameters
Property Description
$request
Illuminate\Http\Request
$proxies
array
Returns
void

protected getTrustedHeaders () : int

Retrieve trusted headers, falling back to trusting no headers, effectively disallowing all proxies.

Returns
int

A bit field of Request::HEADER_*, to set which headers to trust from your proxies.

protected setTrustedProxies (Illuminate\Http\Request $request) : void

Sets the trusted proxies for the request based on the app.trustedProxies configuration option.

Parameters
Property Description
$request
Illuminate\Http\Request
Returns
void
Copyright © 2024 Winter CMS