Skip to content

Commit 305b9ab

Browse files
mathieudzandig
authored andcommitted
Enable trusted proxies in Symfony ^3.3 (#114)
1 parent 4ee4570 commit 305b9ab

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: Bootstraps/Symfony.php

+8
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ public function getApplication()
8080
$app->booted = true;
8181
}, $app);
8282

83+
if ($trustedProxies = isset($_SERVER['TRUSTED_PROXIES']) ? $_SERVER['TRUSTED_PROXIES'] : false) {
84+
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
85+
}
86+
87+
if ($trustedHosts = isset($_SERVER['TRUSTED_HOSTS']) ? $_SERVER['TRUSTED_HOSTS'] : false) {
88+
Request::setTrustedHosts(explode(',', $trustedHosts));
89+
}
90+
8391
return $app;
8492
}
8593

0 commit comments

Comments
 (0)