Forwarded
class Forwarded (View source)
Constants
| IP |
|
| PROTO |
|
| HOST |
|
| PREFIX |
|
| RFC7239 |
|
| DEFAULT_SOURCES |
|
| VALID_SOURCES |
|
| IPV4_MAPPED_PREFIX |
|
| REGEX_RFC7239 |
|
Methods
Creates a new instance
Sets the address ranges (CIDR notation, IPv4 or IPv6) of proxies
Sets the exact addresses of proxies from which forwarded headers are accepted
Sets the hosts accepted when the host comes from a forwarded header. Supported patterns:
example.com*.example.com*(any host)
Set the headers that must/may provide values
Set the headers names
Sets how many trusted proxies are in front of the application.
Get IP
Get protocol/scheme (https or http)
Get host
Get prefix
Details
__construct(array $server, int|null $code = 403)
Creates a new instance
setKnownNetworks(array $networks)
Sets the address ranges (CIDR notation, IPv4 or IPv6) of proxies
setKnownProxies(array $proxies)
Sets the exact addresses of proxies from which forwarded headers are accepted
setAllowedHosts(array $hosts)
Sets the hosts accepted when the host comes from a forwarded header. Supported patterns:
example.com*.example.com*(any host)
Note: entries must be in non-transitional IDNA (UTS #46) ASCII format
setFlags(int $flags)
Set the headers that must/may provide values
setHeaderName(int $flag, string $name)
Set the headers names
setLimit(int $limit)
Sets how many trusted proxies are in front of the application.
In headers with comma-separated values (e.g. X-Forwarded-For, or multiple
Forwarded: entries) the value is taken counting from the end of the list:
1 (default) uses the last entry (appended by the closest proxy), 2 the
second to last, and so on. If the limit is greater than the number of entries,
the first one is used. This prevents clients from spoofing values at the
beginning of the list.
string|null
getIp()
Get IP
string
getProto()
Get protocol/scheme (https or http)
string|null
getHost()
Get host
string
getPrefix()
Get prefix