Symfony Exception

ConflictingHeadersException

HTTP 400 Bad Request

The request has both a trusted "FORWARDED" header and a trusted "X_FORWARDED_HOST" 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.

Exception

Symfony\Component\HttpFoundation\Exception\ ConflictingHeadersException

  1. if (!$this->isForwardedValid) {
  2. return $this->trustedValuesCache[$cacheKey] = null !== $ip ? ['0.0.0.0', $ip] : [];
  3. }
  4. $this->isForwardedValid = false;
  5. throw new ConflictingHeadersException(\sprintf('The request has both a trusted "%s" header and a trusted "%s" 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.', self::TRUSTED_HEADERS[self::HEADER_FORWARDED], self::TRUSTED_HEADERS[$type]));
  6. }
  7. private function normalizeAndFilterClientIps(array $clientIps, string $ip): array
  8. {
  9. if (!$clientIps) {
  1. *
  2. * @throws SuspiciousOperationException when the host name is invalid or not trusted
  3. */
  4. public function getHost(): string
  5. {
  6. if ($this->isFromTrustedProxy() && $host = $this->getTrustedValues(self::HEADER_X_FORWARDED_HOST)) {
  7. $host = $host[0];
  8. } elseif (!$host = $this->headers->get('HOST')) {
  9. if (!$host = $this->server->get('SERVER_NAME')) {
  10. $host = $this->server->get('SERVER_ADDR', '');
  11. }
Request->getHost() in /srv/www/seduo/src/Seduo/Cdn/CdnDetector.php (line 18)
  1. throw new \LogicException('Class is intended for static use only');
  2. }
  3. public static function isCdn(Request $request): bool
  4. {
  5. return str_ends_with($request->getHost(), '.educdn.cz');
  6. }
  7. }
CdnDetector::isCdn() in /srv/www/seduo/src/Seduo/Runtime/SeduoRuntime.php (line 21)
  1. public function getRunner(?object $application): RunnerInterface
  2. {
  3. if ($application instanceof KernelInterface) {
  4. $request = Request::createFromGlobals();
  5. if (!CdnDetector::isCdn($request)) {
  6. $application = new \AppCache($application);
  7. }
  8. return new HttpKernelRunner($application, $request);
  9. }
  1. $app = $app(...$args);
  2. exit(
  3. $runtime
  4. ->getRunner($app)
  5. ->run()
  6. );
require_once('/srv/www/seduo/vendor/autoload_runtime.php') in /srv/www/seduo/web/app.php (line 8)
  1. use Seduo\Runtime\SeduoRuntime;
  2. use Symfony\Component\HttpFoundation\Request;
  3. $_ENV['APP_RUNTIME'] = SeduoRuntime::class;
  4. require_once __DIR__ . '/../vendor/autoload_runtime.php';
  5. require_once __DIR__ . '/../config/bootstrap.php';
  6. Request::setTrustedProxies(
  7. ['REMOTE_ADDR'],
  8. Request::HEADER_X_FORWARDED_FOR |

Stack Trace

ConflictingHeadersException
Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException:
The request has both a trusted "FORWARDED" header and a trusted "X_FORWARDED_HOST" 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 /srv/www/seduo/vendor/symfony/http-foundation/Request.php:2096
  at Symfony\Component\HttpFoundation\Request->getTrustedValues()
     (/srv/www/seduo/vendor/symfony/http-foundation/Request.php:1161)
  at Symfony\Component\HttpFoundation\Request->getHost()
     (/srv/www/seduo/src/Seduo/Cdn/CdnDetector.php:18)
  at Seduo\Cdn\CdnDetector::isCdn()
     (/srv/www/seduo/src/Seduo/Runtime/SeduoRuntime.php:21)
  at Seduo\Runtime\SeduoRuntime->getRunner()
     (/srv/www/seduo/vendor/autoload_runtime.php:29)
  at require_once('/srv/www/seduo/vendor/autoload_runtime.php')
     (/srv/www/seduo/web/app.php:8)