diff --git a/deployment/proxies.rst b/deployment/proxies.rst index c13b9bd0f14..4cf4927965e 100644 --- a/deployment/proxies.rst +++ b/deployment/proxies.rst @@ -137,27 +137,29 @@ these (see ":doc:`/components/http_foundation/trusting_proxies`"). The code for doing this will need to live in your front controller (e.g. ``web/app.php``). -My Reverse Proxy Does not Provide All the Standards Headers ------------------------------------------------------------ +.. _my-reverse-proxy-does-not-provide-all-the-standards-headers: + +My Reverse Proxy Does not Provide All the Standard Headers +---------------------------------------------------------- AWS Elastic Load Balancing for example does not provide the ``X-Forwarded-Host`` and ``X-Forwarded`` HTTP headers, so you must make the following changes in the -front controller:: +front controller: - .. code-block:: diff +.. code-block:: diff - // web/app.php + // web/app.php - // ... - $request = Request::createFromGlobals(); - // be very careful with the next line; see "But what if the IP of my Reverse Proxy Changes Constantly!" - + Request::setTrustedProxies(array('127.0.0.1', $request->server->get('REMOTE_ADDR'))); - // the next line is needed because AWS ELB doesn't send X-Forwarded-Host - + Request::setTrustedHeaderName(Request::HEADER_CLIENT_HOST, null); - // the next line is needed because AWS ELB doesn't use RFC 7239 - + Request::setTrustedHeaderName(Request::HEADER_FORWARDED, null); + // ... + $request = Request::createFromGlobals(); + // be very careful with the next line; see "But what if the IP of my Reverse Proxy Changes Constantly!" + + Request::setTrustedProxies(array('127.0.0.1', $request->server->get('REMOTE_ADDR'))); + // the next line is needed because AWS ELB doesn't send X-Forwarded-Host + + Request::setTrustedHeaderName(Request::HEADER_CLIENT_HOST, null); + // the next line is needed because AWS ELB doesn't use RFC 7239 + + Request::setTrustedHeaderName(Request::HEADER_FORWARDED, null); - // ... + // ... .. _`security groups`: http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-security-groups.html .. _`RFC 7239`: http://tools.ietf.org/html/rfc7239