Skip to content

Commit 48f2c3d

Browse files
javiereguiluzxabbuh
authored andcommitted
Added a minor help note about Request::setTrustedProxies
1 parent 9576bc1 commit 48f2c3d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

components/http_foundation/trusting_proxies.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@ the actual host may be stored in an ``X-Forwarded-Host`` header.
1717

1818
Since HTTP headers can be spoofed, Symfony does *not* trust these proxy
1919
headers by default. If you are behind a proxy, you should manually whitelist
20-
your proxy.
21-
22-
.. versionadded:: 2.3
23-
CIDR notation support was introduced in Symfony 2.3, so you can whitelist whole
24-
subnets (e.g. ``10.0.0.0/8``, ``fc00::/7``).
20+
your proxy as follows:
2521

2622
.. code-block:: php
2723
2824
use Symfony\Component\HttpFoundation\Request;
2925
30-
// only trust proxy headers coming from this IP addresses
26+
// put this code as early as possible in your application (e.g. in your
27+
// front controller) to only trust proxy headers coming from these IP addresses
3128
Request::setTrustedProxies(array('192.0.0.1', '10.0.0.0/8'));
3229
30+
.. versionadded:: 2.3
31+
CIDR notation support was introduced in Symfony 2.3, so you can whitelist whole
32+
subnets (e.g. ``10.0.0.0/8``, ``fc00::/7``).
33+
3334
You should also make sure that your proxy filters unauthorized use of these
3435
headers, e.g. if a proxy natively uses the ``X-Forwarded-For`` header, it
3536
should not allow clients to send ``Forwarded`` headers to Symfony.

0 commit comments

Comments
 (0)