class TrustProxies

Properties

protected null|array<int, string>|string $proxies

The trusted proxies for the application.

protected int $headers

The trusted proxies headers for the application.

static protected null|array<int, string>|string $alwaysTrustProxies

The proxies that have been configured to always be trusted.

static protected int|null $alwaysTrustHeaders

The proxies headers that have been configured to always be trusted.

Methods

Response
handle(Request $request, Closure $next)

Handle an incoming request.

void
setTrustedProxyIpAddresses(Request $request)

Set the trusted proxies on the request.

void
setTrustedProxyIpAddressesToSpecificIps(Request $request, array $trustedIps)

Specify the IP addresses to trust explicitly.

void
setTrustedProxyIpAddressesToTheCallingIp(Request $request)

Set the trusted proxy to be the IP address calling this server.

int
getTrustedHeaderNames()

Retrieve trusted header name(s), falling back to defaults if config not set.

int|string
headers()

Get the trusted headers.

array|string|null
proxies()

Get the trusted proxies.

static void
at(array|string $proxies)

Specify the IP addresses of proxies that should always be trusted.

static void
withHeaders(int $headers)

Specify the proxy headers that should always be trusted.

static void
flushState()

Flush all static state.

Details

at line 47
Response handle(Request $request, Closure $next)

Handle an incoming request.

Parameters

Request $request
Closure $next

Return Value

Response

Exceptions

HttpException

at line 59
protected void setTrustedProxyIpAddresses(Request $request)

Set the trusted proxies on the request.

Parameters

Request $request

Return Value

void

at line 81
protected void setTrustedProxyIpAddressesToSpecificIps(Request $request, array $trustedIps)

Specify the IP addresses to trust explicitly.

Parameters

Request $request
array $trustedIps

Return Value

void

at line 95
protected void setTrustedProxyIpAddressesToTheCallingIp(Request $request)

Set the trusted proxy to be the IP address calling this server.

Parameters

Request $request

Return Value

void

at line 105
protected int getTrustedHeaderNames()

Retrieve trusted header name(s), falling back to defaults if config not set.

Return Value

int

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

at line 128
protected int|string headers()

Get the trusted headers.

Return Value

int|string

at line 136
protected array|string|null proxies()

Get the trusted proxies.

Return Value

array|string|null

at line 147
static void at(array|string $proxies)

Specify the IP addresses of proxies that should always be trusted.

Boot-only. The list persists in a static property for the worker lifetime and applies to every subsequent request.

Parameters

array|string $proxies

Return Value

void

at line 158
static void withHeaders(int $headers)

Specify the proxy headers that should always be trusted.

Boot-only. The header set persists in a static property for the worker lifetime and applies to every subsequent request.

Parameters

int $headers

Return Value

void

at line 166
static void flushState()

Flush all static state.

Return Value

void