@@ -11,9 +11,9 @@ Trusting Proxies
1111
1212If you find yourself behind some sort of proxy - like a load balancer - then
1313certain header information may be sent to you using special ``X-Forwarded-* ``
14- headers. For example, the ``Host `` HTTP header is usually used to return
15- the requested host. But when you're behind a proxy, the true host may be
16- stored ina ``X-Forwarded-Host `` header.
14+ headers or the `` Forwarded `` header . For example, the ``Host `` HTTP header is
15+ usually used to return the requested host. But when you're behind a proxy,
16+ the actual host may be stored inan ``X-Forwarded-Host `` header.
1717
1818Since HTTP headers can be spoofed, Symfony does *not * trust these proxy
1919headers by default. If you are behind a proxy, you should manually whitelist
@@ -26,11 +26,19 @@ your proxy.
2626 // only trust proxy headers coming from this IP addresses
2727 Request::setTrustedProxies(array('192.0.0.1', '10.0.0.0/8'));
2828
29+ You should also make sure that your proxy filters unauthorized use of these
30+ headers, e.g. if a proxy natively uses the ``X-Forwarded-For `` header, it
31+ should not allow clients to send ``Forwarded `` headers to Symfony.
32+
33+ If your proxy does not filter headers appropriately, you need to configure
34+ Symfony not to trust the headers your proxy does not filter (see below).
35+
2936Configuring Header Names
3037------------------------
3138
3239By default, the following proxy headers are trusted:
3340
41+ * ``Forwarded `` Used in:method: `Symfony\\ Component\\ HttpFoundation\\ Request::getClientIp `;
3442* ``X-Forwarded-For `` Used in:method: `Symfony\\ Component\\ HttpFoundation\\ Request::getClientIp `;
3543* ``X-Forwarded-Host `` Used in:method: `Symfony\\ Component\\ HttpFoundation\\ Request::getHost `;
3644* ``X-Forwarded-Port `` Used in:method: `Symfony\\ Component\\ HttpFoundation\\ Request::getPort `;
@@ -39,6 +47,7 @@ By default, the following proxy headers are trusted:
3947If your reverse proxy uses a different header name for any of these, you
4048can configure that header name via:method: `Symfony\\ Component\\ HttpFoundation\\ Request::setTrustedHeaderName `::
4149
50+ Request::setTrustedHeaderName(Request::HEADER_FORWARDED, 'X-Forwarded');
4251 Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, 'X-Proxy-For');
4352 Request::setTrustedHeaderName(Request::HEADER_CLIENT_HOST, 'X-Proxy-Host');
4453 Request::setTrustedHeaderName(Request::HEADER_CLIENT_PORT, 'X-Proxy-Port');
@@ -47,9 +56,9 @@ can configure that header name via :method:`Symfony\\Component\\HttpFoundation\\
4756Not Trusting certain Headers
4857----------------------------
4958
50- By default, if you whitelist your proxy's IP address, then allfour headers
59+ By default, if you whitelist your proxy's IP address, then allfive headers
5160listed above are trusted. If you need to trust some of these headers but
5261not others, you can do that as well::
5362
54- // disables trusting the ``X- Forwarded-Proto `` header, the default header is used
55- Request::setTrustedHeaderName(Request::HEADER_CLIENT_PROTO, '' );
63+ // disables trusting the ``Forwarded`` header
64+ Request::setTrustedHeaderName(Request::HEADER_FORWARDED, null );