From c075d6a6a56b39d766443ff17e35ef148524326d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Fri, 5 Apr 2019 23:54:10 +0200 Subject: [PATCH] Added the support for an env variable HEROKU, which causes, that Symfony trusts all proxies. --- public/index.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/public/index.php b/public/index.php index e30f90c0..74d65eb4 100644 --- a/public/index.php +++ b/public/index.php @@ -20,8 +20,15 @@ if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false Request::setTrustedHosts([$trustedHosts]); } + $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); $request = Request::createFromGlobals(); + +//Set the proxy settings for heroku +if ($_SERVER['HEROKU'] ?? $_ENV['HEROKU'] ?? false) { + Request::setTrustedProxies([$request->server->get('REMOTE_ADDR')], Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST); +} + $response = $kernel->handle($request); $response->send(); $kernel->terminate($request, $response);