Issue:
The solutions above did not work for me. I added the following line of code (as suggested in Symfony2's docs http://symfony.com/doc/current/cookbook/request/load_balancer_reverse_proxy.html#but-what-if-the-ip-of-my-reverse-proxy-changes-constantly) to my web/app.php
:
Request::setTrustedProxies(array($request->server->get('REMOTE_ADDR')));
right after
$request = Request::createFromGlobals();
That solved the problem for me in Symfony 2.5.