File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
components/http_foundation Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,19 @@ stored in a ``X-Forwarded-Host`` header.
12
12
13
13
Since HTTP headers can be spoofed, Symfony2 does *not * trust these proxy
14
14
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
16
22
17
23
use Symfony\Component\HttpFoundation\Request;
18
24
19
25
$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' ));
22
28
23
29
Configuring Header Names
24
30
------------------------
Original file line number Diff line number Diff line change @@ -118,23 +118,27 @@ trusted_proxies
118
118
Configures the IP addresses that should be trusted as proxies. For more details,
119
119
see :doc: `/components/http_foundation/trusting_proxies `.
120
120
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
+
121
125
.. configuration-block ::
122
126
123
127
.. code-block :: yaml
124
128
125
129
framework :
126
- trusted_proxies : [192.0.0.1]
130
+ trusted_proxies : [192.0.0.1, 10.0.0.0/8 ]
127
131
128
132
.. code-block :: xml
129
133
130
- <framework : config trusted-proxies =" 192.0.0.1" >
134
+ <framework : config trusted-proxies =" 192.0.0.1, 10.0.0.0/8 " >
131
135
<!-- ... -->
132
136
</framework >
133
137
134
138
.. code-block :: php
135
139
136
140
$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' ),
138
142
));
139
143
140
144
.. _reference-framework-form :
You can’t perform that action at this time.
0 commit comments