forked from akeneo/pim-community-standard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.php
41 lines (34 loc) · 1.46 KB
/
app.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\HttpFoundation\Request;
require __DIR__.'/../vendor/autoload.php';
$envFile = __DIR__ . '/../.env';
if (file_exists($envFile)) {
(new Dotenv())->load($envFile);
}
$kernel = new AppKernel('prod', false);
//$kernel = new AppCache($kernel);
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
/* In case your app is running behind a reverse-proxy/load-balancer set an environment variable TRUSTED_PROXY_IPS
defining IPs or IP ranges as a comma list (example : TRUSTED_PROXY_IPS="10.0.0.0/8")
to allow usage of X-Forwarded-* headers
This also allows keeping the HTTPS protocol for any URL generated in the PIM */
$loadBalancerTrustedIPs = getenv('TRUSTED_PROXY_IPS');
if (!empty($loadBalancerTrustedIPs)) {
$ipsArray = explode(',', $loadBalancerTrustedIPs);
Request::setTrustedProxies(
// the IP address (or range) of your proxy
$ipsArray,
// trust *all* "X-Forwarded-*" headers
Request::HEADER_X_FORWARDED_ALL
// or, if your proxy instead uses the "Forwarded" header
// Request::HEADER_FORWARDED
// or, if you're using AWS ELB
// Request::HEADER_X_FORWARDED_AWS_ELB
);
}
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);