Skip to content

Commit 95389db

Browse files
committed
Add information about CIDR notation support in trusted proxy list
1 parent ed05a78 commit 95389db

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

components/http_foundation/trusting_proxies.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ stored in a ``X-Forwarded-Host`` header.
1212

1313
Since HTTP headers can be spoofed, Symfony2 does *not* trust these proxy
1414
headers by default. If you are behind a proxy, you should manually whitelist
15-
your proxy::
15+
your proxy.
16+
17+
.. versionadded:: 2.3
18+
CIDR notation support was introduced, so you can whitelist whole
19+
subnets (e.g. ``10.0.0.0/8``, ``fc00::/7``).
20+
21+
.. code-block:: php
1622
1723
use Symfony\Component\HttpFoundation\Request;
1824
1925
$request = Request::createFromGlobals();
20-
// only trust proxy headers coming from this IP address
21-
$request->setTrustedProxies(array(192.0.0.1));
26+
// only trust proxy headers coming from this IP addresses
27+
$request->setTrustedProxies(array('192.0.0.1', '10.0.0.0/8'));
2228
2329
Configuring Header Names
2430
------------------------

reference/configuration/framework.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,27 @@ trusted_proxies
118118
Configures the IP addresses that should be trusted as proxies. For more details,
119119
see :doc:`/components/http_foundation/trusting_proxies`.
120120

121+
.. versionadded:: 2.3
122+
CIDR notation support was introduced, so you can whitelist whole
123+
subnets (e.g. ``10.0.0.0/8``, ``fc00::/7``).
124+
121125
.. configuration-block::
122126

123127
.. code-block:: yaml
124128
125129
framework:
126-
trusted_proxies: [192.0.0.1]
130+
trusted_proxies: [192.0.0.1, 10.0.0.0/8]
127131
128132
.. code-block:: xml
129133
130-
<framework:config trusted-proxies="192.0.0.1">
134+
<framework:config trusted-proxies="192.0.0.1, 10.0.0.0/8">
131135
<!-- ... -->
132136
</framework>
133137
134138
.. code-block:: php
135139
136140
$container->loadFromExtension('framework', array(
137-
'trusted_proxies' => array('192.0.0.1'),
141+
'trusted_proxies' => array('192.0.0.1', '10.0.0.0/8'),
138142
));
139143
140144
.. _reference-framework-form:

0 commit comments

Comments
 (0)