Trusting Proxies

If you find yourself behind some sort of proxy - like a load balancer - then
certain header information may be sent to you using special X-Forwarded-*
headers. For example, the Host HTTP header is usually used to return
the requested host. But when you're behind a proxy, the true host may be
stored in a X-Forwarded-Host header.

Since HTTP headers can be spoofed, Symfony2 does not trust these proxy
headers by default. If you are behind a proxy, you should manually whitelist
your proxy:

1
2
3
4
5

useSymfony\Component\HttpFoundation\Request;$request=Request::createFromGlobals();// only trust proxy headers coming from this IP address$request->setTrustedProxies(array('192.0.0.1'));