Search code examples
androidsymfonyreverse-proxychrome-datasaver

Accessing a Symfony app using Chrome's Data Saver causes BadRequestHttpException


Accessing my Symfony website using Chrome’s Data Saver on Android generates an error 500.

Here is the log

[2017-04-06 18:56:23] request.ERROR: Uncaught PHP Exception
Symfony\Component\HttpKernel\Exception\BadRequestHttpException:
"The request headers contain conflicting information regarding the origin of this request." at /home/myapp/app/bootstrap.php.cache line 3184
{"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException(code: 0): The request headers contain conflicting information regarding the origin of this request. at /home/myapp/app/bootstrap.php.cache:3184, Symfony\\Component\\HttpFoundation\\Exception\\ConflictingHeadersException(code: 0): The request has both a trusted Forwarded header and a trusted Client IP header, conflicting with each other with regards to the originating IP addresses of the request. This is the result of a misconfiguration. You should either configure your proxy only to send one of these headers, or configure Symfony to distrust one of them. at /home/myapp/app/bootstrap.php.cache:788)"} []

From what I understand Chrome’s Data Saver acts as reverse proxy in front of my application compressing code and images.

I read this doc about how to use a reverse proxy in front of a Symfony app.

The problem is I don't find any doc about the IP Chrome’s Data Saver proxy is using.

Thanks for help!


Solution

  • The crucial information lies here:

    The request has both a trusted Forwarded header and a trusted Client IP header

    I would recommend fixing the issue or - if you don't have permissions - disable the conflicting header as described in the documentation:

    You probably want to do this in your app.php or app_dev.php in your web/ directory. Right after the $request is created.