Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit af8bd77

Browse filesBrowse files
committed
Merge pull request symfony#2287 from lazyhammer/trusted-proxies-cidr
[WaitingCodeMerge] Add information about CIDR notation support in trusted proxy list
2 parents cd824e0 + 95389db commit af8bd77
Copy full SHA for af8bd77

File tree

Expand file treeCollapse file tree

2 files changed

+16
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-6
lines changed

‎components/http_foundation/trusting_proxies.rst

Copy file name to clipboardExpand all lines: components/http_foundation/trusting_proxies.rst
+9-3Lines 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

Copy file name to clipboardExpand all lines: reference/configuration/framework.rst
+7-3Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.