File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
components/http_foundation Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -17,19 +17,20 @@ the actual host may be stored in an ``X-Forwarded-Host`` header.
17
17
18
18
Since HTTP headers can be spoofed, Symfony does *not * trust these proxy
19
19
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:
25
21
26
22
.. code-block :: php
27
23
28
24
use Symfony\Component\HttpFoundation\Request;
29
25
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
31
28
Request::setTrustedProxies(array('192.0.0.1', '10.0.0.0/8'));
32
29
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
+
33
34
You should also make sure that your proxy filters unauthorized use of these
34
35
headers, e.g. if a proxy natively uses the ``X-Forwarded-For `` header, it
35
36
should not allow clients to send ``Forwarded `` headers to Symfony.
You can’t perform that action at this time.
0 commit comments