我有一个使用Symfony 3.2的应用程序,从昨天开始运行良好。当我尝试访问应用程序时,我有一个BadRequestHttpException,它告诉我在我的请求中有两个http标头冲突:FORWARDED和X_FORWARDED_FOR。
Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException (code:
0):The request headers contain conflicting information regarding the origin
of this request. at /home/biotekagee/gdpl/var/cache/prod/classes.php:4630,
Symfony\\Component\\HttpFoundation\\Exception\\ConflictingHeadersException (code:
0): The request has both a trusted \"FORWARDED\" header and a trusted
\"X_FORWARDED_FOR\" header, conflicting with each other. You should either
configure your proxy to remove one of them, or configure your project to
distrust the offending one. at
/home/biotekagee/gdpl/var/bootstrap.php.cache:1297
我注意到的事情:
$kernel = new AppCache($kernel)
问题解决了。我想那个问题来自HttpCache我已经和Symfony合作了不到一年,我还是一个菜鸟,这个错误确实让我很紧张。我希望有人能够帮助我。
我首先在app.php
中添加了这一行来解决问题
Request::setTrustedHeaderName(Request::HEADER_FORWARDED, null);
不是一个好的解决方案...然后,我从Symfony 3.2更新到Symfony 3.3,问题似乎已经消失。